Sql last week

This article is tagged with: Sql last week and mysql

sql last week

select min(date), max(date)
from calendar
where week = datepart(week, getdate() - 7)
and year = datepart(year, getdate() - 7)

sql select data from last week

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

This article is tagged with: Sql last week and mysql