How long does it take to become a software engineer?
Normally, software engineers at large companies have a bachelors degree in computer science. That's four years of college after high school. That's not the only way, though! Especially at smaller companies, what matters is often what experience and skills you have, more than how long you went to school. So if you are really passionate about it, and work on your own projects and study and build skills on your own, it's possible to work as a software engineer with any level of education.
The other side of your question is how long you have to actually do computer programming to develop the skills for the job. Like most things, becoming an expert can take a lot of time. A good rule of thumb is that it takes at least 10,000 hours of practice to become a world-class expert at anything! That's a lot: about 5 years even if you do it full time. The trick to getting through that is to find something you love, and be careful to enjoy yourself along the way.