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)
 how to convert instants to datetime

Author  Topic 

cjcclee
Starting Member

33 Posts

Posted - 2013-08-02 : 12:01:07

5446287969, it is the number of seconds since midnight of 12/31/1840, how can I convert this number to date? Thank you!

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2013-08-02 : 12:10:16
[code]SELECT DATEADD(SECOND, 5446287969 % 86400, DATEADD(DAY, 5446287969 / 86400, '18410101'))[/code]
Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-08-03 : 00:13:19
shouldnt it be from '18401231')

if you mean from start of 12/31/1840(0000 hours)

SELECT DATEADD(ss,5446287969%86400,'18401231')+FLOOR(5446287969/86400)


if you mean end of 12/31/1840 then its 0000 hours of 01/01/1841


SELECT DATEADD(ss,5446287969%86400,'18410101')+FLOOR(5446287969/86400)


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -