Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

TimeZone conversion in sql server 2008 Expand / Collapse
Author
Message
Posted Monday, February 4, 2013 2:07 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Monday, April 29, 2013 1:59 AM
Points: 53, Visits: 101
How i can convert my timezone in sql server,

My requirement is to save date in client time zone not as UTC, and in another sp i need to convert these time to UTC.


Is there any to convert time zone in sql server 2008?
Post #1415182
Posted Monday, February 4, 2013 3:44 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, December 12, 2014 10:09 AM
Points: 2,876, Visits: 5,201
Do you know in what "zone" your datetime is saved? If not, then there is no way to convert it reliably to UTC.
Usually, if your system needs to be designed to cater for different time zones, you would save the datetime in UTC form, and convert it based on locale...


_____________________________________________
"The only true wisdom is in knowing you know nothing"
"O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!"
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
Post #1415206
Posted Monday, February 4, 2013 3:59 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Monday, April 29, 2013 1:59 AM
Points: 53, Visits: 101
Yes, I know the zone of saved date. Other than this i have saved date in UTC but in this case i need to save date of local time with zone.
Post #1415213
Posted Monday, February 4, 2013 4:11 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, December 12, 2014 10:09 AM
Points: 2,876, Visits: 5,201
There is datetimeoffset T-SQL function to help you. You will need to keep time offset in form of [+|-] hh:mm, in order to use it.



_____________________________________________
"The only true wisdom is in knowing you know nothing"
"O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!"
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
Post #1415214
Posted Monday, February 4, 2013 4:37 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Monday, April 29, 2013 1:59 AM
Points: 53, Visits: 101
Does is support Day Light Saving as well ?
Post #1415227
Posted Monday, February 4, 2013 4:49 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, December 12, 2014 10:09 AM
Points: 2,876, Visits: 5,201
This function applies offset to the given datetime. You need to keep or calculate somehow proper offset, in order to apply it.

http://msdn.microsoft.com/en-gb/library/bb630289.aspx






_____________________________________________
"The only true wisdom is in knowing you know nothing"
"O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!"
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
Post #1415231
Posted Saturday, May 3, 2014 4:07 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, May 23, 2014 7:52 AM
Points: 1, Visits: 13
Check out T-SQL Toolbox on CodePlex: http://tsqltoolbox.codeplex.com

It offers easy datetime conversion UDFs using plain T-SQL!
Post #1567238
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse