SQL语句查询当天/七天内/一个月的数据

今天的所有数据:select * from 表名 where DateDiff(day,datetime字段,getdate())=0
 
昨天的所有数据:select * from 表名 where DateDiff(day,datetime字段,getdate())=1
 
7天内的所有数据:select * from 表名 where DateDiff(day,datetime字段,getdate())<=7
 
30天内的所有数据:select * from 表名 where DateDiff(day,datetime字段,getdate())<=30
 
本月的所有数据:select * from 表名 where DateDiff(mm,datetime字段,getdate())=0
 
本年的所有数据:select * from 表名 where DateDiff(yy,datetime字段,getdate())=0

注:DateDiff 前可以添加过滤条件