t.end_time_ 换成你的时间字段
-- 今天的数据 00:00:00-23:59:59
and t.end_time_ BETWEEN CONVERT(varchar(100), GETDATE(), 23) +' 00:00:00' AND CONVERT(varchar(100), GETDATE(), 23) +' 23:59:59'
-- 本周的数据 周一到周日
and t.end_time_> DATEADD(wk, DATEDIFF(wk,0,DATEADD(dd, -1, getdate()) ), 0) and t.end_time_<DATEADD(wk, DATEDIFF(wk,0,DATEADD(dd, -1, getdate()) ), 7)
--本月的数据
and datediff(month, t.end_time_,getdate())=0

 

相关文章: