Click here to Skip to main content
15,919,358 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
DateDifference,years with months...like 2.3(2 years 3 months)
Posted

Not very elegant but this should work

SQL
SELECT CAST( DATEDIFF(yy, '2013-01-01', '2015-04-01') AS VARCHAR(2)) +' years '
      + CAST( DATEDIFF(MM, '2013-01-01', '2015-04-01')%12 AS Varchar(2)) +' months '
 
Share this answer
 
SQL
DECLARE @DIFF AS INT

SET @DIFF = DATEDIFF(MM, '2013-01-01', '2015-04-01')

SELECT @DIFF / 12, @DIFF % 12
 
Share this answer
 
I tried this, it is working now perfectly
Thank you for your solutions

Solution: convert(decimal(10,1),DATEDIFF(MM,DateStart,GETDATE())/12.0) as Experience
 
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