How can I get the correct offset between UTC and local times for a date that is before or after DST?
35
votes
11
answers
232354
views
I currently use the following to get a local datetime from a UTC datetime:
SET @offset = DateDiff(minute, GetUTCDate(), GetDate())
SET @localDateTime = DateAdd(minute, @offset, @utcDateTime)
My problem is that if daylight savings time occurs between
GetUTCDate()
and @utcDateTime
, the @localDateTime
ends up being an hour off.
Is there an easy way to convert from utc to local time for a date that is not the current date?
I'm using SQL Server 2005
Asked by Rachel
(8557 rep)
Nov 5, 2012, 01:25 PM
Last activity: Dec 9, 2020, 09:58 PM
Last activity: Dec 9, 2020, 09:58 PM