前30天convert(nvarchar(10),dateadd(day,-30,getdate()),120)
当月月初convert(varchar(10),dateadd(day,0,getdate()-day(getdate()-1)),120)
当月月末convert(varchar(10),dateadd(month,1,getdate()-day(getdate())),120)
其它非时间格式的表达计算
:rk_rq月初近两月
rq>=convert(datetime,convert(varchar(4),year(:rk_rq))+'-'+convert(varchar(2),month(:rk_rq))+'-'+convert(varchar(2),day(:rk_rq)))-day(:rk_rq)+1
and rq<convert(datetime,convert(varchar(4),year(:rk_rq))+'-'+convert(varchar(2),month(:rk_rq)+2)+'-'+convert(varchar(2),day(:rk_rq)))-day(:rk_rq)+1
本文转自 qvodnet 51CTO博客,原文链接:http://blog.51cto.com/bks2015/1607438