
SQL 根据员工出生日期写生日提醒
员工出生日期格式是:1990-6-26有若干个员工写出SQL(SqlServer2008)根据不同查询时间(getdate())查询出所有满足未来45天内生日的员工信息还...
员工出生日期格式是:1990-6-26
有若干个员工
写出SQL(Sql Server 2008)根据不同查询时间(getdate())
查询出所有满足未来45天内生日的员工信息
还是自己贴答案大家分享下吧
SELECT E.Code,E.Name,E.BornDate,D.NAme AS sDept,ZW.Name AS SZhiWu ,E.PyDate ,datediff(DAY,DATEADD(Year,DATEDIFF(Year,BornDate ,getdate()),BornDate),getdate()) as cyts
FROM ZlEmployee E
LEFT JOIN ZlDept D ON E.Dept=D.Code
LEFT JOIN E_ZhiWu ZW ON E.ZhiWu=ZW.Code
where datediff(DAY,DATEADD(Year,DATEDIFF(Year,BornDate ,getdate()),BornDate),getdate())between 0 and 45
and E.state not in ('09')
order by datepart(day,E.Borndate),E.code 展开
有若干个员工
写出SQL(Sql Server 2008)根据不同查询时间(getdate())
查询出所有满足未来45天内生日的员工信息
还是自己贴答案大家分享下吧
SELECT E.Code,E.Name,E.BornDate,D.NAme AS sDept,ZW.Name AS SZhiWu ,E.PyDate ,datediff(DAY,DATEADD(Year,DATEDIFF(Year,BornDate ,getdate()),BornDate),getdate()) as cyts
FROM ZlEmployee E
LEFT JOIN ZlDept D ON E.Dept=D.Code
LEFT JOIN E_ZhiWu ZW ON E.ZhiWu=ZW.Code
where datediff(DAY,DATEADD(Year,DATEDIFF(Year,BornDate ,getdate()),BornDate),getdate())between 0 and 45
and E.state not in ('09')
order by datepart(day,E.Borndate),E.code 展开
1个回答
展开全部
SELECT *
FROM 员工表
WHERE 出生日期>=getdate()
AND 出生日期<DATEADD(day, getdate(), 45)
FROM 员工表
WHERE 出生日期>=getdate()
AND 出生日期<DATEADD(day, getdate(), 45)
追问
呵呵,这语句很有艺术
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询