SQL TODATETIMEOFFSET

SQL TODATETIMEOFFSET function is one of the Date and Time Function, which is used 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 TO DATE TIME OFFSET Function is as follows:

TODATETIMEOFFSET (datetime2(or Expression), time_zone)

You can use Hours such as +13.00, -12.00, or Minutes like 120, 240 as the time_zone

SQL TODATETIMEOFFSET Function Example

In this Date and Time Function example, we will show you the use of SQL Server To Date Time Offset function

-- Example for SQL Server TODATETIMEOFFSET 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
SQL TODATETIMEOFFSET 1