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 2008 Forums
 Transact-SQL (2008)
 Calculating Time

Author  Topic 

ross_gt
Starting Member

23 Posts

Posted - 2011-07-20 : 12:44:31
I have a column with a date format like '20110720'. I would like to figure out the time elapse between data. So for i have a calculation like this : ('20110720'-launchdate)/365. I get a result; however, its too high. I want an answer like 3.5 years or 2.8 years. Can anyone think of a better calculation to get me a result like this?

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-07-20 : 13:54:40
DATEDIFF(day, launchdate, '20110720')/365.0
Go to Top of Page

ross_gt
Starting Member

23 Posts

Posted - 2011-07-20 : 14:18:51
I just tried that and I receive this error:

Msg 8115, Level 16, State 2, Line 1
Arithmetic overflow error converting expression to data type datetime.
Go to Top of Page

ross_gt
Starting Member

23 Posts

Posted - 2011-07-20 : 14:24:11
Nevermind I got it. Thank you so much!
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-07-20 : 14:49:24
Glad you got it sorted out
Go to Top of Page
   

- Advertisement -