Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 DateDiff as Decimal

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-01-24 : 08:45:55
Chris writes "I am trying to get the difference between two dates as a decimal. The SQLSERVER DateDiff function rounds to an even whole number year. Here is what I have tried

DATEDIFF(year, dd.hire_date, getdate()) as YearsOfService

I'd like to see the result as .17, 2.75.

Thank you,
Chris"

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-01-24 : 09:15:02
select convert(decimal(12,2), DATEDIFF(m, dd.hire_date, getdate())/12.00) as YearsOfService

Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -