I need to convert a datetime stored as UTC to a specific timezone, stored in another column.
For example, given this table:
Date | TimeZone -----------------+--------------- 2017-05-15 11:17 | Europe/Madrid 2017-01-01 11:17 | Europe/Madrid 2017-05-15 11:17 | US/Pacific 2017-01-01 11:17 | US/Pacific
I should get this result:
Date ---------------- 2017-05-15 13:17 2017-01-01 12:17 2017-05-15 04:17 2017-01-01 03:17
Please note I'm using SQL Server 2012, so I can't use AT TIME ZONE
. Is there any way to achieve this without post-processing the data?