Determine if daylight saving time is active? SQL Server
问题 I have a table with users, UTC time offset, and if they observe daylight saving time. Is there a built in way to get the correct user time? 回答1: Right now I'm doing this: SELECT CASE USEDAYLIGHTSAVING WHEN 1 THEN CASE DATEDIFF(HH,GETUTCDATE(),GETDATE()) -- I know the server is set to Mountan time and follows daylight saving time -- MDT = -6 -- MST = -7 WHEN -6 THEN DATEADD(HH,TIMEZONEOFFSET+1,GETUTCDATE()) ELSE DATEADD(HH,TIMEZONEOFFSET,GETUTCDATE()) END ELSE DATEADD(HH,TIMEZONEOFFSET