SQL TODATETIMEOFFSET function is one of the Date and Time Functions, which is useful to return a datetimeoffset value from the users specified datetime2, and time zone. This function returns datetimeoffset data type value as output. The basic syntax of the SQL Server TODATETIMEOFFSET Function is as follows:
TODATETIMEOFFSET (datetime2(or Expression), time_zone)
You can use Hours such as +13.00, and -12.00, or Minutes like 120, and 240 as the time_zone
SQL TODATETIMEOFFSET Function Example
In this Date and Time Function example, we will show the use of SQL Server To Date Time Offset function
SELECT GETDATE() AS Today -- Change Time Zone using Hours SELECT TODATETIMEOFFSET (GETDATE(), '-06:00') AS Result SELECT TODATETIMEOFFSET (GETDATE(), '+05:30') AS Result -- Changing Time Zone using Minutes SELECT TODATETIMEOFFSET (GETDATE(), -150) AS Result SELECT TODATETIMEOFFSET (GETDATE(), 240) AS Result