By Samantha Bomkamp, AP Transportation Writer

NEW YORK (AP) — You scour websites. You set up fare alerts. But the real secret in getting the best price for an airline ticket boils down to two things: when you look and when you book.

Trouble is, not all peak travel times are created equal. The sweet spot when tickets are cheapest can vary by weeks, according to travel data analyzed by Expedia for The Associated Press.

Take the next two big travel weekends for example. Based on an analysis of ticket prices over the last four years, Expedia has found that the best time to book for the Fourth of July was between one and two months in advance.

Jump ahead to Labor Day, in September, and the rules change dramatically. Those looking to travel that weekend, based on trends since 2007, can get the best deal buying 3 or 4 weeks in advance. Prices jump 10% from their lowest points if you wait 1 to 2 weeks out. They're 30% higher, on average, if you book less than a week before summer's last hoorah.

But how can two holiday weekends so close together have such different rules for snagging cheap fares?

Expedia analyst Daniel Kissin said it's all in the timing. Fourth of July, although it's more of a popular driving holiday, still gets loads of people in the skies every year. Labor Day, on the other hand, isn't as popular because it usually coincides with back to school.

Following the old fashioned rule of supply and demand, it makes sense to book early for the most popular travel holidays: Thanksgiving, Christmas, Memorial Day. At other times of the year, though, it's better to gamble and hold out for that cheaper fare closer to your travel date.

TheStreet Recommends

The rules of low fares are evolving quickly as airlines recover from the recession. Last year, procrastination was the name of the game.

Because travel demand was sluggish, airlines discounted seats or launched fare sales close to flight time. But this year, travel demand is inching up and airlines have slimmed their fleets. That means fewer seats with more demand — the perfect equation for higher fares.

Even though airlines are trying to raise fares across the board, it's clearly not all working out. On less-traveled weekends, consumers with an eye for bargains still have a leg up.

Certain destinations also have different rules. Procrastinators with island dreams, listen up: That flight to Hawaii will be cheaper the more you wait.

The reason? Kissin said because Hawaii is a more expensive destination, travelers tend to book earlier. The airlines know that. And if flights aren't full within a couple weeks of departure, discounts are bound to pop up.

The same could be said about flights overseas to Europe, Asia or other hot spots — so keep a steady hand. A cheaper fare might be a few days away.

When you're ready to book that flight, don't forget to book the hotel, too. Expedia spokesman Adam Anderson says booking separately is one of the biggest money-losing mistakes people make. Reserving everything together online could save you hundreds of dollars depending on the price of your trip.

Copyright 2010 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.

—For the best rates on loans, bank accounts and credit cards, enter your ZIP code at