DateTime and DateTimeOffset

for more information, reference: https://blogs.msdn.microsoft.com/bartd/2009/03/31/the-death-of-datetime/

As of SQL 2008 a new and improved DateTime datatype is available, called DateTimeOffset.

I suspect it will be difficult for many coders to move away from the DateTime datatype, however there are several benefits to using the DateTimeOffset datatype.

The DateTimeOffset stores the current time as well as the offset of that time from UTC time. This becomes useful when comparing DateTimes that occurred across time zones, or between Daylight Savings Times.

The DateTimeOffset requires upto 2 extra Bytes over the original DateTime DataType.

SELECT SYSDATETIMEOFFSET()

Identify what your SQL SErvers UTF offset currently is:

SELECT DATENAME (TZoffset, SYSDATETIMEOFFSET())

–Variable provided calculated.

DECLARE @N DATETIMEOFFSET;
SET @N = GETDATE();
SELECT TODATETIMEOFFSET (@N, DATENAME (TZoffset, SYSDATETIMEOFFSET()))