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?
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];
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).
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With