SQL SWITCHOFFSET Function

SWITCHOFFSET returns a datetimeoffset with a specified timezone.

This function does not change the underlying datetime value, only the display value.

Example

#

This example changes the timezone offset to +8:00 on the specified input datetimeoffset.

SELECT SWITCHOFFSET ('2022-09-28 8:54:16.1234 -5:00', 
                     '+08:00') AS '+8:00 Offset'
Result:  1 record
+8:00 Offset
2022-09-28 21:54:16.1234000 +08:00

Syntax

Syntax of the SWITCHOFFSET function .

SWITCHOFFSET(datetime, offset) 

datetime -- a datetime or column name.

offset -- an offset expression or signed integer representing timezone offset.


You may also like



Guides


vsn 3.1