本周:select * from table where datediff(week,C_CALLTIME,getdate())=0 --C_CALLTIME 为日期字段
本月:select * from table where datediff(Month,C_CALLTIME,getdate())=0 --C_CALLTIME 为日期字段
本季:select * from table where datediff(qq,C_CALLTIME,getdate())=0
前半年1-6,后半年7-12:select * from table where datepart(mm,C_CALLTIME)/7 = datepart(mm,getdate())/7
本文来自优快云博客,转载请标明出处:http://blog.youkuaiyun.com/eyu777/archive/2009/06/18/4280303.aspx
本文介绍如何使用SQL语句筛选特定时间段的数据,包括本周、本月、本季及上半年或下半年的数据查询方法,适用于需要定期进行时间维度数据分析的场景。
823

被折叠的 条评论
为什么被折叠?



