Philip
Philip

Reputation: 407

How to find the difference between joining date and current date of and employee

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

Answers (2)

Jimmy Miller
Jimmy Miller

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

aF.
aF.

Reputation: 66757

Difference in days:

SELECT DATEDIFF( dd , e.JoiningDate, getdate())
FROM employee e

Upvotes: 0

Related Questions