phillymatt
phillymatt

Reputation: 1

Selecting mysql records for next week

I'm looking for the MySQL query to select date records that fall within the next week using Sunday - Saturday as the format for the week.

So in other words, I'm not looking to get the dates a week from today, I'm looking to get the dates that fall within Sunday - Saturday of the next week.

I found this: MySQL Query to select data from last week? and it works for the previous week from Sunday - Saturday but I'm not sure how to tweak this to get the dates for the next week.

Any ideas?

Upvotes: 0

Views: 440

Answers (2)

genespos
genespos

Reputation: 3311

You can use:

SELECT *
FROM YourTable
WHERE WEEK(YourDateField, 6) = WEEK(CURRENT_DATE + INTERVAL 7 DAY, 6)

for selecting recods of next week (starting with sunday)
Weeks count is 1 to 53 with first week of the year having at least 4 days in the year

Upvotes: 0

khodayar J
khodayar J

Reputation: 914

SELECT * FROM table
WHERE 
date > date_add(curdate(),INTERVAL(7-dayofweek(curdate()))DAY) 
AND date <= date_add(curdate(),INTERVAL(14- dayofweek(curdate()))DAY)

Upvotes: 1

Related Questions