Click here to Skip to main content
15,894,343 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I'm a newbie to SQL server. Please let me know how to retrieve data based on dates in tables.

For example: To retrieve Lists of employees who have been in the organisation for more than 5 years based on hired-date(yy:mm:day format) in Employee details.

Thanks in advance
Posted

1 solution

try this
select *
from <tablename>
where DATEDIFF(YEAR,<hireddate-colname>,GETDATE())>5
 
Share this answer
 
v2

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