Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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....
Posted

SQL
select *
from table1
where datejoined < DATEADD(year, -5, DATEDIFF(dd, 0, GETDATE()))
 
Share this answer
 
v3
You can use the ADD function[^].
E.g. select * from table where coldateofjoining > DATEADD(year, -5, GETDATE())
 
Share this answer
 
v2
Hi rani,
Please find my query below.

select * from employees where datediff(yy,getdate(),date_of_join)>=5
 
Share this answer
 
Comments
Schatak 7-Apr-14 3:59am    
What are you doing? you are providing a very wrong query here..
deenasudhakar 13-Apr-14 11:48am    
Schatak,

Can u explain my very wrong query.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900