Starting with SQL server 2016 the AT TIME ZONE function will output the inputdate into the correct time zone offset. The inputdate being of smalldatetime, datetime,datetime2 or datetimeoffset. if your inputdate includes offset information then the AT TIME ZONE function will use a set of time zone conversion rules. The inputdate will be returned as a datetimeoffset data type in the chosen time zone.
Example
The below example I have decalred two datetime2 variables one date before British day light savings and the other after British daylight savings.
1 2 3 4 5 6 |
set dateformat dmy; declare @preDST datetime2 = '10-03-2019 06:59:00', @postDST datetime2 = '10-04-2019 07:00:00'; select @preDST at time zone 'GMT Standard Time' AS [PreDST should be +00:00], @postDST at time zone 'GMT Standard Time' AS [PostDST should be +01:00]; |