sql查询语句查询一周内一月内记录

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

select * from tb_user where datediff('d',log_time,now())=0
select * from tb_user where datediff('d',log_time,now())=1
select * from tb_user where datediff('d'log_time,now())=7
select * from tb_user where datediff('d'log_time,now())=30




上一星期(七天之内):
select * from art where [now] between dateadd('ww',-1,now()) and now()
上一星期(上周一至周日):
select * from art where [now] between dateadd("d",-Weekday(Now())-5,now()) and dateadd("d",-Weekday(Now())+1,now())
上一月(上月的今天至今天):
select * from art where [now] between dateadd("m",-1,now()) and now()
上一月(1号至最后一天):
select * from art where [now] between dateserial(year(now),month(now())-1,1) and dateserial(year(now),month(now()),1-1)



asp+access标准
select case fastFind
case "所有的团购信息"
sql="SELECT * FROM tbl_group order by RequireDate desc"
case "今天的团购信息"
sql="SELECT * FROM tbl_group where RequireDate=date()"
case "最近一周内的团购信息" --上一周的今天到今天--
sql="SELECT * FROM tbl_group WHERE RequireDate between dateadd('ww',-1,now()) and now()"
case "最近一月内的团购信息" --上一月的今天到今天--
sql="SELECT * FROM tbl_group WHERE RequireDate between dateadd('m',-1,now()) and now()"
end select

相关文档
最新文档