This article is half-done without your Comment! *** Please share your thoughts via Comment ***
SQL Server 2016 introduced an AT TIME ZONE Expression to select a different type of TIME ZONEs.
If your application is multi-location and distributed over the world, I would suggest applying UTC date time format on your important date-time columns.
The reason is, you can insert UTC format anywhere from the world, and while selecting those data, you can change it into local TIME ZONE. So it will give you full flexibility on your date-time columns.
Now, you can use AT TIME ZONE expression for converting your date-time value in different TIME ZONEs.
Below is a demonstration of this:
Create a table with sample record:
1 2 3 4 5 6 7 8 9 10 11 |
CREATE TABLE tbl_TestTime ( DayTime1 DATETIME ,DayTime2 DATETIME ,DayTime3 DATETIME ) GO INSERT INTO tbl_TestTime VALUES ('2016-08-08 12:11:30','2016-08-08 12:11:30','2016-08-08 12:11:30') GO |
Use AT TIME ZONE and SELECT your date-time value in different time zones:
1 2 3 4 5 |
SELECT DayTime1 AT TIME ZONE 'Eastern Standard Time' AS EST ,DayTime2 AT TIME ZONE 'Pacific Standard Time' AS PST ,DayTime3 AT TIME ZONE 'Central European Standard Time' AS CEST FROM tbl_TestTime |
Using below query, You can check available time zones:
1 2 |
SELECT * FROM sys.time_zone_info GO |
Leave a Reply