Now stop the whining about all here that everybody should be able to play a G on the top of the staff in two years, it's too variable to say that. I could hit the G after 2.5 years, with an average teacher, and now I gig a couple of times a month, have a pro teacher found since a year, and can play a solid G above the G we're talking about.
It all just depends on the education you get, and the amount of practicing, if you try to teach yourself, especially in the beginning, there are unknown things to try to find out out of nowhere, therefore, especially when you start, find a teacher, it doesn't have to be a top level pro teacher, but any professional teacher will help significantly and they will let you know what and how to practise.
The main issue on this level is either a very bad habit or lack of air, try to breath from down below, take very deel breaths, and play with lots of air. And confidence, have you ever hit the G? So then why can't you hit it another time? Trumpet playing is a lot of a moral issue.
You're asking about time, well:
G: If you study right (how?) and a lot, I'ld say a couple of months
High C: A couple of years.
With a teacher:
G: Might be instantly, or in a few weeks
High C: If you work hard, then in a year you will have a High C, squeky or solid.
+ you get of all your bad habits.
Summarized: If you want to make real progress, find a teacher, even if it's only for some months, and play with confidence and lots of air.
What horn do you play? Just interested.