sql 判断时间

来源:百度知道 编辑:UC知道 时间:2024/05/06 00:58:03
where datediff(month,a.inputDate,getdate())=0 --判断本月
----------- 前一个月
----------- 前2个月
------------------------------今年
上面的的时间 必须要在同同一年里面哦

呵呵,楼主,其实你自己就写出来了哦,只完善下就可以呀
----------- 前一个月
datediff(month,a.inputDate,getdate())=1
----------- 前2个月
datediff(month,a.inputDate,getdate())=2
------------今年
datediff(year,a.inputDate,getdate())=0

前一个月
month(a.inputDate)=month(getdate())-1
前2个月
month(a.inputDate)=month(getdate())-2
今年
year(a.inputDate)=year(getdate())