0

I want to select all data from a table where a last_update field is 'this week'. So between the previous Sunday, and the upcoming Saturday.

I found this answer that finds dates LAST Week, but I can't quite figure out how to tailor it for what I need, which is this calendar week.

SELECT * FROM items
WHERE last_update >= curdate() - INTERVAL DAYOFWEEK(curdate())+6 DAY
AND last_update < curdate() - INTERVAL DAYOFWEEK(curdate())-1 DAY
4

1 回答 1

3

I think I found the answer on this one:

SELECT * FROM items
WHERE last_update >= curdate() - INTERVAL DAYOFWEEK(curdate())-1 DAY
AND last_update <= curdate() + INTERVAL 7 DAY - DAYOFWEEK(curdate())
于 2012-11-14T20:59:23.573 回答