Inventors frequently ask how long will it take before a patent will issue. This seemingly straightforward question, however, is not so straightforwardly answered. First, you might not get a patent. Your claims might be rejected and you might decide to abandon the application. Or you might appeal to the Board of Patent Appeals and Interferences (which is becoming more frequent) and lose. Or you might seek further appeal at the Federal Circuit, and lose.
Second, depending on the type of invention for which you are seeking patent protection, the length of time it takes for the examiner to issue a first office action can vary widely. The closely followed patent blog, PatentlyO (http://www.patentlyo.com/), recently summarized in a table the average time to first office action by art area. For example, on average it takes 3.5 years for a first office action for business method patent applications, 3.2 years for computer networks, 2.2 years for machine elements, 1.9 years for amusement devices, and 1.7 years for manufacturing devices. Assuming a first office action allowance (a big assumption), you still would have to pay the issue fees and await issue, at least another 4 to 6 months. But most cases are not allowed on first office action, so there will be a second office action, and perhaps a request for continued examination, and then possibly the appeals mentioned above.
Third, much more rare, a secrecy order could get slapped on your patent, and you could be denied a patent entirely if granting a patent on your invention is considered a threat to national security.
When it comes to patenting, therefore, the old adage rings true: most people overestimate what they can accomplish in 6 months, and underestimate what they can accomplish in 5 years---that is, if they stick with it.