SWITCHOFFSET
SWITCHOFFSET is a Transact-SQL function in Microsoft SQL Server that changes the time zone offset of a datetimeoffset value while preserving the same absolute (UTC) moment in time. It returns a datetimeoffset value whose local time is adjusted so that the underlying UTC instant remains unchanged.
Syntax and usage typically appear as:
SWITCHOFFSET(datetimeoffset_value, target_offset)
where target_offset is a string in the form '+HH:MM' or '-HH:MM'. For example, SWITCHOFFSET('2021-03-15 10:00:00 -05:00',
- The function shifts the local datetime by the difference between the original offset and the target
- It accepts datetimeoffset inputs and produces datetimeoffset outputs.
- It does not perform time zone name-based conversions or apply daylight saving time rules; it operates
- For conversions that require time zone rules or DST awareness, the AT TIME ZONE construct (introduced
- SWITCHOFFSET differs from TODATETIMEOFFSET: TODATETIMEOFFSET attaches a specified offset to a datetime value without preserving the
Common uses include normalizing stored datetimeoffset values to a standard offset (such as UTC) or displaying