SQL Server
查询昨天的数据
select * from table where datediff(day, 时间字段,getdate()) = 1
1
查询今天的数据
SELECT *...))=0;
1
查询上周的数据
select * from checkinfo where datediff(week, 时间字段 ,getdate()) = 1;
1
查询下周的数据
select...DateDiff(month, 时间字段, GetDate()) = 1;
1
查询本月的数据
select * From checkinfo Where DateDiff(month, 时间字段,...Where DateDiff(year, GetDate(), c_sample_date ) = 0
MySQL
查询今天的数据
select * from table where to_days...(时间字段) = to_days(now());
1
查询本周的数据
SELECT * FROM table WHERE YEARWEEK( date_format(时间字段名,'%Y-%m-%d'