MySQL Query to select data from last week? MySQL Query to select data from last week? database database

MySQL Query to select data from last week?


select id from tbnamewhere date between date_sub(now(),INTERVAL 1 WEEK) and now();


SELECT id FROM tblWHERE date >= curdate() - INTERVAL DAYOFWEEK(curdate())+6 DAYAND date < curdate() - INTERVAL DAYOFWEEK(curdate())-1 DAY


SELECT id FROM table1WHERE YEARWEEK(date) = YEARWEEK(NOW() - INTERVAL 1 WEEK)

I use the YEARWEEK function specifically to go back to the prior whole calendar week (as opposed to 7 days before today). YEARWEEK also allows a second argument that will set the start of the week or determine how the first/last week of the year are handled. YEARWEEK lets you to keep the number of weeks to go back/forward in a single variable, and will not include the same week number from prior/future years, and it's far shorter than most of the other answers on here.