Home > Net >  MySQL Get same day of previous week data
MySQL Get same day of previous week data

Time:05-14

Let say today is Wednesday, I need to get all records from same day (Wednesday) of previous week. How to achieve this in MySQL statement condition?

CodePudding user response:

On a given day e.g. Wednesday the previous Wednesday would be today - 7 days. So:

select *
from t
where date_column >= current_date - interval 7 day
and   date_column <  current_date - interval 6 day

CodePudding user response:

SELECT *
 FROM Table
 where ( (datetime between date()-7 and date()) ) order by datetime DESC
  • Related