Trying to choose the best time to buy a plane ticket can be an excruciating decision. There's always that moment after you've got your ticket booked when you see that they're $50 cheaper and you know there's nothing you can do about it.

Traveling internationally is even harder. You may know a year ahead of time that you want to take an international flight, but when is the right time to buy? Three months, six months, nine months ahead of time?

Lucky for us, there's data that tells us the best time to book a flight. Expedia (EXPE 0.29%) recently published a report called Preparing for Takeoff: Air Travel Trends 2015 that will help you save money on your travel plans.

The best time to book a domestic flight
Before you go and buy a domestic plant ticket a year ahead of time, just to make sure there's a seat, you may want to consider waiting a couple of months to see if prices fall, because planning too far ahead can cost you.

If you're looking for the optimal day to book, according to Airlines Reporting Corporation, or ARC, data, the best time to book a flight is 57 days in advance of your travels. In reality, there's a long window between 50-100 days before you travel when ticket prices are lowest. And savings can add up versus planning too far ahead, too; tickets acquired 57 days before liftoff are $95 less than the average ticket price.

Source: Preparing for Takeoff: Air Travel Trends 2015.

It should be no surprise that waiting until the last minute is the worst thing you can do if you want to save money on domestic flights. Ticket prices skyrocket between 25 days before a flight and day-of, so avoid procrastination if you're worried at all about budget.

When to book an international flight
Booking flights internationally are even more nerve wracking. If you're like me, you've stressed about when to book a long flight abroad, often on trips that are planned as much as a year ahead of time. The good news is that there's not a big penalty for planning ahead on international flights. In fact, as long as you book at least 75 days ahead of time, there's not a bad time to book your flight.

Source: Preparing for Takeoff: Air Travel Trends 2015.

According to ARC data, the best window to book is between 150-225 days before an international flight, and the best day is 171 days in advance.

While the savings of $364 from the average ticket price seems like a lot, the average price is skewed by a huge spike in prices during the final weeks before an international flight when last minute travel plans pick up. But if you can plan ahead a few months you'll get close to the best price you can on those long flights.

Knowing when to buy is half the battle
Hopefully this data provides at least a small amount of peace of mind when booking your next flight. You may not pick the cheapest date for any given flight but knowing that you're buying at the optimal time can save a lot of money over planning too far ahead or too late before you fly.

Now you know that 57 days ahead for domestic flights and 171 day ahead for international are statistically the best times to book. Happy travels.