SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Store date in GMT
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

146 Posts

Posted - 08/25/2010 :  16:26:16  Show Profile  Reply with Quote
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))

Patron Saint of Lost Yaks

30407 Posts

Posted - 08/25/2010 :  16:40:13  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000