TODATETIMEOFFSET returns a datetimeoffset from the specified datetime.
The fractional precision is the same as the datetime value provided.
This example returns a timezoneoffset with +8:00 for the specified date.
SELECT TODATETIMEOFFSET ('2022-09-28 8:54:16', '+08:00')
AS 'Datetime Offset'
| Datetime Offset |
|---|
| 2022-09-28 08:54:16.0000000 +08:00 |
Syntax of the TODATETIMEOFFSET function .
TODATETIMEOFFSET(datetime, offset)
datetime -- a datetime2 value or column name.
offset -- a timezone offset or signed integer representing from +14 to -14.