①当天
(OperateTime >=CONVERT(varchar(10),getDate(),120)+' 00:00:00' and OperateTime <=CONVERT(varchar(10),getDate(),120)+' 23:59:59')
②近三天
DateDiff(day,OperateTime,getdate()) <=3
③本周
sql数据库
Datepart(year,OperateTime)=DatePart(year,Getdate()) and DatePart(week,OperateTime)=DatePart(week,GetDate())
Access 数据库
Datepart('yyyy',OperateTime)=DatePart('yyyy',date()) and DatePart('ww',OperateTime)=DatePart('ww',Date())
④本月
Datepart(year,OperateTime)=DatePart(year,Getdate()) and DatePart(month,OperateTime)=DatePart(month,GetDate())
注:OperateTime是表中日期字段
Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved. 闵涛 E_mail:admin@mintao.net(欢迎提供学习资源)
鄂公网安备 42011102001154号
站长:MinTao ICP备案号:鄂ICP备11006601号-18