TimeZone conversion in sql server 2008

  • 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?

  • 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!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • 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.

  • 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!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • Does is support Day Light Saving as well ?

  • 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!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • Check out T-SQL Toolbox on CodePlex: http://tsqltoolbox.codeplex.com

    It offers easy datetime conversion UDFs using plain T-SQL!

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply