TODATETIMEOFFSET()
TODATETIMEOFFSET() is a SQL function in the Date/Time Functions category. SQL Server: converts a datetime to DATETIMEOFFSET by applying a timezone offset. The syntax is TODATETIMEOFFSET(datetime, timezone). It accepts datetime, timezone. It returns offset-applied datetime. A typical example: SELECT TODATETIMEOFFSET('2026-06-06 14:30:00', '+08:00'); -- 2026-06-06 14:30:00 +08:00 -- Unlike SWITCHOFFSET, this does not change the time value -- It simply adds the offset to a offset-naive time -- Difference: -- TODATETIMEOFFSET: '14:30' -> '14:30 +08:00' (same clock time) -- SWITCHOFFSET: '14:30 +00:00' -> '22:30 +08:00' (same moment) -- Useful for: converting local times to DATETIMEOFFSET A close relative is NOW(), which returns the current date and time as a timestamp. A close relative is CURDATE(), which returns the current date without time. A close relative is DATE(), which extracts the date part from a datetime expression. More about this category: Date and time functions — NOW, DATE, EXTRACT, DATEDIFF, DATE_ADD, DATE_FORMAT.