SQL Server full time zone conversion

Source: Internet
Author: User
Tags time zones

SQL Server full time zone conversion

If your application is used across borders (such as cross-border bank transactions), then some of the internationalization features of the database can be said to be very important.

The most common of these are the differences in time zones, because SQL Server getdate () reads the values returned by the local machine.

does not contain database time zone displacements, SQL Server2008 new DateTimeOffset data type (time of day based on time zone)

With the Switchoffset function to more easily handle time zone conversion problems

--Time zone ConversionSELECTSysdatetimeoffset () as"Taipei (GMT+8:xx) ", Switchoffset (Sysdatetimeoffset (),'+09:00') as"Janpen (GMT+9:xx) ", Switchoffset (Sysdatetimeoffset (),'-10:00') as"Hawaii (GMT-Ten:xx)"

-- get the time zone shift in Taipei Select DATEDIFF (MI, Sysdatetimeoffset (),getdateas'timezoneoffset' )
480 min/60 min=8 HR
--Read Job system login get GMT and DST namesDECLARE @GMTname VARCHAR( -),@DSTname VARCHAR( -); EXECXp_regread "HKEY_LOCAL_MACHINE", "SYSTEM\CurrentControlSet\Control\TimeZoneInformation", "StandardName",@GMTnameOUTPUTEXECXp_regread "HKEY_LOCAL_MACHINE", "SYSTEM\CurrentControlSet\Control\TimeZoneInformation", "DaylightName",@DSTnameOUTPUTSELECT @GMTname  as 'GMT (Gmt:greenwich Mean time)',@DSTname  as 'Daylight Saving time (Dst:daylight saving time)'

Reprinted from: Http://www.dotblogs.com.tw/ricochen/archive/2012/10/30/79754.aspx

SQL Server full time zone conversion

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.