I have a large table with DateTime values that need to be converted to DateTimeOffset.
I can do this by using the following statement, which retains the date/time and adds the current time zone offset.
TODATETIMEOFFSET([StatisticDateUTC], DATENAME(tz, SYSDATETIMEOFFSET()))
The problem is some of these values represent dates years ago, some in daylight savings, some not, so it's actually incorrect to put the current offset in all of them. Some of them should have an offset of -700 some should have an offset of -800.
If the time zone was consistent for all of the values, how can I get the correct offset? I know how this can be done in .net, as there are a nice set of functions to do it, but I need a pure sql solution, no CLR functions.