用SQL实现生日提醒功能
3天后生日的:
select * from staff where datepart(m,staff_time)=datepart(m,getdate()) and datepart(d,staff_time)=datepart(d,getdate())+3
几天生日的:
select * from staff where datepart(m,staff_time)=datepart(m,getdate()) and datepart(d,staff_time)=datepart(d,getdate())
3天内生日的:
select * from staff where datepart(m,staff_time)=datepart(m,getdate()) and datepart(d,staff_time)>=datepart(d,getdate()) and datepart(d,staff_time)<=datepart(d,getdate())+3
- 本文标题: SQL实现生日提醒
- 文章分类:【SQLServer】
- 非特殊说明,本文版权归【胡同里的砖头】个人博客 所有,转载请注明出处.