When it comes to filling up your gas tank for the cheapest price, the day of the week matters.

A new study by GasBuddy identified the cheapest and most expensive days of the week to buy gasoline in all 50 states, based on a data of daily statewide fuel prices over the past year.

According to this analysis, GasBuddy found that Sunday is the most consistently affordable day to fill up in most states. Midweek, particularly Wednesday through Friday, tends to be more expensive.

And that holds true for drivers in New York state.

According to GasBuddy’s study, the best day of the week for New York drivers to fill their gas tank is Sunday. The worst day is Thursday.

GasBuddy said that, in most states, prices gradually rise through the week before easing into the weekend.

“Gas prices don’t just move based on global oil markets — they also follow a weekly rhythm,” said Patrick De Haan, head of petroleum analysis at GasBuddy. “For most drivers, Sunday is the safest bet for finding lower prices, while filling up mid-week can mean paying more.”

As of Friday, the national average gas price in the United States is $2.93, according to AAA.

In New York state, the average gas price is $2.99, according to the data.