The website I'm working on has a dashboard showing the data entered by various users during the previous week. I select this data with a simple WHERE clause:
SELECT * FROM table WHERE WEEK(date, 1) = WEEK(CURDATE(), 1) - 1
However, the New Year is coming soon, and when the user tries to view the dashboard, for example, on January 3 or 4, my code is clearly going to give me the wrong result, because last week the number 2010 is 52. So, what will be the best way to change my request to take into account the change of the year. In addition, it would be great to make it possible to select the data entered 2, 3, 4, ... weeks ago.
source
share