如何从sql中的emp表中获取加入时间超过5年的日期 [英] how to get date of joining greater than 5 years from emp table in sql
本文介绍了如何从sql中的emp表中获取加入时间超过5年的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请有人告诉我如何从sql的emp表中获取加入时间超过5年的日期,
请帮我解决这个问题.. ..
Hi, please some one tell that how to get date of joining greater than 5 years from emp table in sql,
pls help me to solve this....
推荐答案
select *
from table1
where datejoined < DATEADD(year, -5, DATEDIFF(dd, 0, GETDATE()))
您可以使用ADD
功能 [ ^ ]。
例如select * from table coldateofjoining> DATEADD(年,-5,GETDATE())
You can use theADD
function[^].
E.g.select * from table where coldateofjoining > DATEADD(year, -5, GETDATE())
你好rani,
请在下面找到我的查询。
select *来自员工,其中datediff(yy,getdate(),date_of_join)> = 5
Hi rani,
Please find my query below.
select * from employees where datediff(yy,getdate(),date_of_join)>=5
这篇关于如何从sql中的emp表中获取加入时间超过5年的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文