SqlServerTimeZoneSupport icon indicating copy to clipboard operation
SqlServerTimeZoneSupport copied to clipboard

Need a ToDateTimeOffset function

Open mattjohnsonpint opened this issue 10 years ago • 1 comments

We have no direct function to convert datetime or datetime2 values to datetimeoffset with the correct offset for a particular time zone.

It can be done with two functions, as in:

Tzdb.SwitchZone(Tzdb.LocalToUtc(@local, @tz, 1, 1), @tz)

But this should be wrapped in a single function.

mattjohnsonpint avatar Oct 08 '15 17:10 mattjohnsonpint

And while wrapping the above will work, it could probably be written better as a single lookup against the Interval table.

mattjohnsonpint avatar Oct 08 '15 17:10 mattjohnsonpint