You need to know how long your invention is protected.
The quick answer to "how long is a patent good for" is 20 years. However, that answer has to be qualified for several reasons. The clock starts when you first file your patent. You have put the world on notice that this is your idea and you are claiming exclusive privilege to it. If your patent is awarded 2 years later, then you have 18 more years to exploit the value of your idea without outside competition. Or more accurately the patent give you the legal right to challenge those who may be infringing on your patent claims.
The 20 year patent is a non-provisional patent. Another very short term patent is available called the provisional patent. It is good for a year. It is also a very informal patent. It only requires a short description of your idea, with the factors that make it unique. There are generally no claims or drawings required. It is a placeholder. It is like you are telling the world that you have an idea that you want to protect, but you don't have the time or money to develop a full patent right now.
How does this affect the patent life when you get the full patent? The clock starts when you first file, even when the first filing is a provisional patent.
The question of "how long is a patent good for" is twenty years. Even though the general answer is 20 years, you must understand when the clock starts clicking. This information is specifically for patents filed in the USA.