SQLTeam.com | Weblogs | Forums

Alternative to At Time Zone

#1

Hello,

I have a situation where I need to change time zones from GMT standard time to UTC time. On my home computer I have SQL Server 2016. The following query gives me the result I need

SELECT Received_Date,Start_Date, End_Date, Target_Date,
Received_Date AT TIME ZONE 'GMT Standard Time' AS ReceivedDate_TimeZoneGMT,
Received_Date AT TIME ZONE 'GMT Standard Time'
AT TIME ZONE 'UTC' AS ReceivedDate_TimeZoneUTC,
Start_Date AT TIME ZONE 'GMT Standard Time' AS StartDate_TimeZoneGMT,
Start_Date AT TIME ZONE 'GMT Standard Time'
AT TIME ZONE 'UTC' AS StartDate_TimeZoneUTC,
End_Date AT TIME ZONE 'GMT Standard Time' AS EndDate_TimeZoneGMT,
End_Date AT TIME ZONE 'GMT Standard Time'
AT TIME ZONE 'UTC' AS EndDate_TimeZoneUTC,
Target_Date AT TIME ZONE 'GMT Standard Time' AS TargetDate_TimeZoneGMT,
Target_Date AT TIME ZONE 'GMT Standard Time'
AT TIME ZONE 'UTC' AS TargetDate_TimeZoneUTC
FROM #OrderDate

At work I am using SQL server 2012 and AT TIME ZONE is not compatible with SQL prior to 2016.

What is the equivalent in 2012 that will get me the same outcome?

Any help much appreciated (fairly new to SQL)

Vinnie