[学习笔记]Sql提前30天提醒信息

select *,datediff(day, (dateadd(month,0,getdate())),CertificateTime),Rmind=case 
when ( CertificateTime between getdate() and dateAdd(dd,30,getdate())) then ('请注意,您的健康证即将到期') 
when datediff(day, (dateadd(month,0,getdate())),CertificateTime)<=0 then ('请注意,您的健康证已过期')
else '' 
end
from HealthCertificate

你可能感兴趣的:([学习笔记]Sql提前30天提醒信息)