查询当天/本周/本月/本季度/本年的数据(sqlserver and access)

sqlserver 查询当天/本周/本月/本季度/本年的数据
当天数据:select * from tableName where datediff(day, 字段名,getdate())=0
本周数据:select * from tableName where datediff(week, 字段名,getdate())=0
本月:select * from tableName where datediff(month, 字段名,getdate())=0
本季度:内select * from tableName where datediff(quarter, 字段名,getdate())=0
本年:select * from tableName where datediff(year, 字段名,getdate())=0

access 
查询当天:DateDiff('d',time,Date())=0
查询当月:datediff('m',time ,date())=0
查询当年:DateDiff('yyyy',time,date())=0 

  

posted @ 2020-11-20 00:51  你好柴九  阅读(624)  评论(0编辑  收藏  举报