Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determining remote daylight saving in sql server

I want to determine the if daylight saving time is active or not, but in a region different to where my server is located.

My problem is I want to check the daylight saving of London and my server is in Canada; is it possible to find the daylight saving of a different time zone?

like image 411
Rohit Vyas Avatar asked Apr 26 '13 08:04

Rohit Vyas


People also ask

How does SQL handle day light saving?

DST Conversions DECLARE @PreDST datetime2 = '2019-03-10 06:59:00', @PostDST datetime2 = '2019-03-19 07:00:00'; SELECT @PreDST AT TIME ZONE 'Eastern Standard Time' AS [PreDST should be -05:00], @PostDST AT TIME ZONE 'Eastern Standard Time' AS [PostDST should be -04:00];

How do you know if daylight savings is on or off?

Most of the United States begins Daylight Saving Time at 2:00 a.m. on the second Sunday in March and reverts to standard time on the first Sunday in November. In the U.S., each time zone switches at a different time. In the European Union, Summer Time begins and ends at 1:00 a.m. Universal Time (Greenwich Mean Time).

How do I find the time zone in SQL Server?

SQL Server users typically fetch the local timezone by using the GETDATE() function with insert/update statements or as a default constraint for a datetime column in a select statement.


1 Answers

You need to deploy a table of DST and look up the DST time for the region you want. DST are published by various organizations and refreshed periodically. What you need to understand is that DST cannot be determined by an algorithm, it can only be looked up as is set by various legislative bodies for various regions, and changes frequently. For example here is the current 2013 DST table. Maintaining your application's DST look-up table current would be a periodic task for your application.

like image 154
Remus Rusanu Avatar answered Sep 22 '22 15:09

Remus Rusanu