SQL Server
查询昨天的数据
select * from table where datediff(day, 时间字段,getdate()) = 1
1
查询今天的数据
SELECT *...FROM checkinfo where DATEDIFF(day,时间字段,GETDATE())=0;
1
查询昨天的数据
SELECT * FROM checkinfo where DATEDIFF...(day,时间字段,GETDATE())=1;
1
查询本周的数据
SELECT * FROM checkinfo where datediff(week,c_sample_date,getdate(...))=0;
1
查询上周的数据
select * from checkinfo where datediff(week, 时间字段 ,getdate()) = 1;
1
查询下周的数据
select...GetDate()) = 0;
1
查询下月的数据
Select * From checkinfo Where DateDiff(month,时间字段,GetDate()) = -1;
1
查询最近七天的数据