At Time Zone

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.

 

Showing Results of AT TIME ZONE function in SQL SERVER
Showing the Results of AT TIME ZONE

 

Leave a Reply

Your email address will not be published. Required fields are marked *