There’s an SQL Server who uses GETDATE()
in UTC+1, so it’s prone to different local times. In summer, it yields +02:00
(CEST), while in winter, it’s +01:00
(CET).
Getting the timezone offset of the current time is easy. How to get the UTC offset for historic dates?
The date actually speaks for itself—if it’s between 1 o’clock UTC on the last Sundays in March and October respectively, it’s DST, otherwise it’s not. But that’s a cumbersome heuristic to apply to each query.
I can’t seem to use SYSDATETIMEOFFSET()/TODATETIMEOFFSET/SWITCHOFFSET/DATENAME(TZOFFSET,…)
because I’d need to already know the offset. In this very instance, AT TIME ZONE/sys.time_zone_info
drop out, because it’s an older 2014 SQL server.
That’s got to be a standard issue. Aside from using UTC dates or storing the offset to each date, isn’t there a reasonable way to get the DST offset from any date in a specific (geographical) timezone?