Some may say a year in advance, and depending on who you ask you may come across different answers, but what I find best is 6-8 months of structured training leading up to an event works best. There are so many things that go with this though that I feel I must touch on all aspects regarding time and training load.
I've heard that the longer you can train the better for endurance sports
This statement is correct in the right context. While you do get better in endurance sports over years of training (up to about 50 years old +/- 5) the goal here is not to have a focus on a big event the entire time. Some of the best adaptations you can make in your body are the coffee shop bike rides, easy 3-5 mile runs, or 1 hour of cross training that doesn't seem to have any other purpose then getting outdoors. However, if your "A" race is in July and you are pushing yourself in October or November, you are pushing too early. Simply enjoy the ride/run/ski/etc and save the mind games for Jan-July
Why is it bad to focus on the event more than 6 months in advance?
This is just to long to maintain physical form and mental sharpness. The body can build up for 2-3 peaks in an optimal year for best results. If you start to build in November for a July race and ramp up training, the likely scenario is that you will either plateau your fitness over time, overtrain, become injured, or burn out from the mental exhaustion of continuous training. This is often a mistake of new athletes thinking they will continue training from one season to the next and make huge changes.
This isn't to say its bad to train when you're further than 6 months out. Again, remember years of endurance training build an aerobic base that is needed. However, having a focus and structured training for an event a long time out is what I would caution against.
So when should I structure my training and how do I do that?
This is why you hire a coach! About 6 months is the amount of time I see fit if you go from non-specific to specific. What this might look like for a 40km TT athlete prepping for state championships is
Month 1: Slowly build volume
Month 2: slowly add in 75-80% effort with some volume
Month 3: Bring in shorter efforts with some 5-8 min 95-105% efforts
Month 4: Build duration of volume and efforts up to 10-15 min
Month 5/6: 15-30 min 90-105% efforts mixed in with some volume.
So as you get closer to the event, you start to get more and more specific to the race and what it will need from your body. The whole time you are building fitness through volume, frequency and intensity of training, but you are doing so in a way that allows your last 2 months to be very race specific.
So what should my main take-away be?
There is a time and place to train hard and specific to your race. That time is not all year! I assume because we are in February, most of you will be targeting big races within the next 6 months. That means now is the time for you to come off your un-structured "off-season" and start to slowly build back into a consistent training pattern with a thought or two about your big event. However, if you don't have your big event for the year until October... don't push too early. You will stall out and not satisfy your overall goals.