Click here to Skip to main content
15,895,256 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to calculate the work experience of employee from Joining date to Current Date using Sql Server 2005

My column name for joining date is jDate, I need to Minus the difference from Joining to Current Date.

Please help.
Thanks.
Posted

SQL
SELECT
    EMPLOYEEID, EMPLOYEENAME,

    convert(varchar(3),DATEDIFF(MONTH, jDate, GETDATE())/12) +' years '+
    convert(varchar(2),DATEDIFF(MONTH, jDate, GETDATE()) % 12)+ ' months'
    AS EXPERIENCE,


FROM EMPLOYEE
 
Share this answer
 
v2
Have a look at this

TSQL Datediff[^]

I have modified the query on that page, this one shows the number of days, but if you look at the article you will see there are many different options that you can use to measure the difference between the dates.

SQL
USE AdventureWorks;
GO
SELECT DATEDIFF(day, jDate, GETDATE()) AS NumberOfDays
FROM YourTableName;
GO
 
Share this answer
 

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