0

I am facing the issue that I need to convert between different time zones. I found a solution for SQL Server version 2016 using AT TIME ZONE. Is there also an easy solution for SQL Server 2014?

Something like following would be great:

SELECT CONVERT(datetime, '2018-01-01 01:00:59') -- Datetime in Alaska
AT TIME ZONE 'Central European Standard Time';  -- Datetime in Europe
d219
  • 2,707
  • 5
  • 31
  • 36
Lazloo Xp
  • 858
  • 1
  • 11
  • 36
  • 1
    Why do you assume the original time is in Alaska's timezone? If you deploy to any cloud environment or data center it will probably be UTC. If your data is sensitive to timezones use `datetimeoffset` at least. I'd also suggest storing the IANA timezone name. Offsets change due to DST changes, timezone names don't. – Panagiotis Kanavos Mar 12 '18 at 09:11
  • And look at this link - https://stackoverflow.com/questions/19613638/sql-server-convert-datetime-into-another-timezone – Abhishek Mar 12 '18 at 09:13
  • It does not have to be necessary alaska but can be any time zone where the server is located. What do you mean by IANA time zone name and how can I apply it? – Lazloo Xp Mar 12 '18 at 09:19
  • See dup answer for options in SQL 2014. If it were 2016, you would use *two* `AT TIME ZONE` statements, the first would assert the time zone (Alaska) of the provided value, the second would convert to the desired time zone (Europe). – Matt Johnson-Pint Mar 12 '18 at 16:57

0 Answers0