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
 Date Conversion Question

Author  Topic 

stharish
Starting Member

43 Posts

Posted - 2011-12-23 : 14:18:16
Hello,

I have a table of aircraft flights with departure and arrival times in the following format: 2012-04-18 19:30:00.0000000 -07:00

I'm assuming the -07:00 in the example above is a timezone offset. The departure in the example is displaying a 19:30 Local departure from Oakland, CA on 4/18/2012.

Question: How can I get these departure/arrival times to display in UTC (ZULU) time? Is it possible with the information in these fields?

Thanks

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2011-12-23 : 16:37:27
My understanding is that the Date you listed above is the Local Date Time with the Offset to UTC. So, in order to convert it into a UTC date you can do something like this:

SELECT CONVERT(DATETIME, CAST('2012-04-18 19:30:00.0000000 -07:00' AS DATETIMEOFFSET), 127)

EDIT: I'm not sure what format your "Date" is stored in. If it is a string, then it is not ISO8601 compliant and might not convert properly or as exptected depending on your computers date time regional settings.
Go to Top of Page

stharish
Starting Member

43 Posts

Posted - 2011-12-23 : 17:28:13
Times are stored as datetimeoffset(7)
Go to Top of Page
   

- Advertisement -