I've been searching all morning and can't seem to get a handle on this (though I do have a few possible theories). It's also not impossible that this might be a duplicate but please take into account that all the questions I searched, didn't give a definitive answer but were rather too open to interpretation.
In SQL Server (>= 2012), a table column of type datetime
, is it stored timezone offset agnostic or is how does it work? From my investigation, it would seem that datetimeoffset
is the type that includes the offset with the date/time while datetime
simply omits this?
When I read the data from the database, and use CONVERT( datetimeoffset, [My Column] )
it's giving me 2016-09-21 16:49:54.7170000 +00:00
while myself and the server are both in UTC +02:00 which reinforces my belief, am I correct?
What I'm trying to achieve, is allow data to be saved FROM various tz offsets (via a function), then saved into the database in UTC and finally convert the datetime
value back to a (possibly different) offset. I don't care about DST / etc as the users browser will give me the current offset at the time of the saving and the viewing user will give me their tz offset at the time of viewing. For historic reports the exact time of day (DST dependent) is irrelevant.
Currently the database tables already use datetime
as opposed to datetimeoffset
; it's my observation that it's completely fine to continue with this, though at some point, it might be good to change to datetimeoffset
in order to then have start recording the historic tz offset?
Any clarity will be greatly appreciated.