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
 Store date in GMT

Author  Topic 

Apples
Posting Yak Master

146 Posts

Posted - 2010-08-25 : 16:26:16
If I'm passing in a date to a query, can I convert it to GMT in SQL?

Something like:

INSERT INTO tblTest (Date)
VALUES (GMT(@mydate))

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-08-25 : 16:40:13
Only if you know the timezone for which the date and time is entered.
Then use DATEADD(HOUR, +/-x, OriginalDateTime) to calculate the GMT.

Or, if you are using SQL Server 2008 or later, use DATETIMEOFFSET datatype.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -