34,593
社区成员
发帖
与我相关
我的任务
分享
update MarketingCaseExpire
set ProjectEndState=case
when DATEDIFF(month, getdate() , ProjectEndTime)=0 then '当月到期'
when DATEDIFF(month, getdate() , ProjectEndTime)<0 then '已到期'
when DATEDIFF(month, getdate() , ProjectEndTime)=1 then '下月到期'
when DATEDIFF(month, getdate() , ProjectEndTime)>1 then '2个月后到期'
end,
CurrentMonthExpire=case
when DATEDIFF(month, getdate() , ProjectEndTime)=0 then 1
else 0
end,
Expired=case
when DATEDIFF(month, getdate() , ProjectEndTime)<0 then 1
else 0
end,
TwoMonthsAfterExpired=case
when DATEDIFF(month, getdate() , ProjectEndTime)>1 then 1
else 0
end,
OneMonthsAfterExpired=case
when DATEDIFF(month, getdate() , ProjectEndTime)=1 then 1
else 0
end