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
 Transact-SQL (2000)
 UTC timecode convert

Author  Topic 

marcuscoker
Starting Member

13 Posts

Posted - 2006-08-30 : 09:21:28
Hi

Was wondering if anybody could help me

I have a date field in an off the shelf application that uses SQL as a backend
The date field is in the UTC timecode format ie seconds since 01/01/1970 (i think)

Does anybody know how i could go about converting this 1142322277 into a date dd/mm/yyyy

Thanks

Marcus

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-08-30 : 09:23:51
[code]select dateadd(second, 1142322277, '19700101'),
convert(varchar, dateadd(second, 1142322277, '19700101'), 103)[/code]

Peter Larsson
Helsingborg, Sweden
Go to Top of Page

marcuscoker
Starting Member

13 Posts

Posted - 2006-08-30 : 09:33:27
Many thanks Peter

Just tried, converts the date

Thank you
Go to Top of Page

Arnold Fribble
Yak-finder General

1961 Posts

Posted - 2006-08-30 : 09:44:36
If it's really the number of UTC seconds, wouldn't you have to take account of leap-seconds?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-08-30 : 09:48:33
Yes, you can have a table for which times a leap second occured.

A leap second can be either positive or negative depending on the Earth's rotation. Since the first leap second in 1972, all leap seconds have been positive and there were 23 leap seconds in the 34 years to January, 2006. This pattern reflects the general slowing trend of the Earth due to tidal braking.

I think MVJ can provide more information about this.
Also see [url]http://en.wikipedia.org/wiki/Leap_second[/url].


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-08-30 : 11:38:30
My guess is that it is not UTC time, but 32-bit UNIX time.

I believe that most UNIX systems handle the leap second issue with the simple method of ignoring them.

This external link explains how time is calculated on UNIX systems.
Unix Time:
http://en.wikipedia.org/wiki/Unix_time





CODO ERGO SUM
Go to Top of Page
   

- Advertisement -