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
 General SQL Server Forums
 New to SQL Server Programming
 Convert SQL To Regular Date/Time

Author  Topic 

dzach
Starting Member

38 Posts

Posted - 2008-12-10 : 11:30:25
I have a SQL database that stores one of the time fields as seconds (I think), and looks like this: 1228893733. I have a query that converts the SQL time to regular date/time, but it's off by one hour (trying to convert to MST). Here's my query:

Select DateAdd(ss, LastOccurTime, '1969-12-31T18:00:00.000') as OccurTime
From Event



Suggestions on how to fix are appreciated!

Thanks
Dale

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2008-12-10 : 11:45:38
[code]Select DateAdd(ss, LastOccurTime-3600, '1969-12-31T18:00:00.000') as OccurTime
From Event[/code]
or

[code]Select DateAdd(ss, LastOccurTime-3600, '1969-12-31T18:00:00.000') as OccurTime
From Event[/code]

..depending on whether you are ahead or behind.
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2008-12-10 : 11:46:31
add 3600 to the 2nd query.

Go to Top of Page

dzach
Starting Member

38 Posts

Posted - 2008-12-10 : 12:00:01
Thanks!
Go to Top of Page

hanbingl
Aged Yak Warrior

652 Posts

Posted - 2008-12-10 : 12:06:06
its confusing when you don't specify the correct answer. Ist supposed to be 2008-12-10 1:22:13 or 00:22:13?? Why start with 1969-12-31 6pm?
Go to Top of Page
   

- Advertisement -