Using SQL Server 2016, I have a date_time
column of type DATETIME
that was inserted using the machine's local time zone. I need to convert this value to UTC.
I tried using
CONVERT(NVARCHAR(19), date_time AT TIME ZONE 'UTC', 127) + 'Z' AS Timestamp
but I realize now that it automatically assumes the date_time
is already in UTC time so no conversion is made. I am not using DATEADD
because it does not account for DST.
Is there a way I can tell SQL Server that the date time is in the machine's local time zone, then use AT TIME ZONE to convert it to UTC?
Edit: This is not a duplicate, since a comment in the approved answer ("Yea, but it assumes that the input time is UTC, which is pointless if you want to convert from local time to UTC") states the problem I have outlined in this question.