今天在写一个程序时,需要统计本周,本月的数据,Google了一下,把统计方法记录如下,方便下次使用:
本周:select * from table where datediff(week,fdate,getdate())=0
本月:select * from table where datediff(Month,fdate,getdate())=0
本季:select * from table where datediff(qq,fdate,getdate())=0
前半年1-6,后半年7-12:select * from table where datepart(mm,fdate)/7 = datepart(mm,getdate())/7
