现在的位置: 首页 > 综合 > 正文

TSQL查询本周本月的数据(转)

2012年08月31日 ⁄ 综合 ⁄ 共 374字 ⁄ 字号 评论关闭
本周: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://www.cnblogs.com/zhuawang/archive/2008/06/18/743118.html

抱歉!评论已关闭.