Reputation: 407
How can I find the difference between the joining date of an employee and the current date, using a select query?
The employee table contains the joining date.
Upvotes: 0
Views: 5341
Reputation: 1319
SELECT DATEDIFF(datepart, JoinDate, GETDATE()) AS TimeInService FROM Employee
The datepart represents the type of boundary crossed in the calculation. Minutes, Seconds, Days, etc. The DATEDIFF documentation will help you sort that out.
Upvotes: 1
Reputation: 66757
Difference in days:
SELECT DATEDIFF( dd , e.JoiningDate, getdate())
FROM employee e
Upvotes: 0