All your life, son.
That's how long it takes a screenwriter to learn about screenwriting. It never gets easier. Some scripts aren't as challenging as others, but even the upper echelon screenwriters of past and present generations wrote some turkeys.
If you're going to be a screenwriter don't do it in a half-assed way. You've got to be all in.
You've got to commit and stay with it. Try to write 3 or 4 screenplays a year. Or even 5.
The important thing is to write. Start the next one a couple of days after you finish one. When you finish that one, start another.
You're only going to get good by writing.
If you're lucky maybe by screenplay #5 you'll get a deal.
If not, maybe screenplay #10.
You have to keep writing and learning and writing and learning.
Then write some more.