T-SQL Tutorial

Datetimeoffset - TSQL Tutorial


On Transact SQL language the datetimeoffset is part of date and time data types and define a date that is combined with a time of a day that has time zone awareness.

Datetimeoffset syntax:

datetimeoffset [ (fractional seconds precision) ]

PropertyValue
Default string literal formatYYYY-MM-DD hh:mm:ss[.nnnnnnn] [{+|-}hh:mm]
Range0001-01-01 - 9999-12-31
Length26 minimum - 34 maximum
Storage size10 bytes

Datetimeoffset example:

USE model;
GO
DECLARE @datetimeoffset datetimeoffset(3) = '2014-08-21 10:49:32.1234 +10:0';
DECLARE @datetime2 datetime2(3)=@datetimeoffset;
SELECT @datetimeoffset AS 'Datetimeoffset', @datetime2 AS 'Datetime2';
GO

DatetimeoffsetDatetime2
2014-08-21 10:49:32.123 +10:002014-08-21 10:49:32.123