Quantcast
Viewing all articles
Browse latest Browse all 12198

DATEDIFF with Datetimeoffset data

When doing DATEDIFF with datetimeoffset data, the datetimeoffset data will be converted to UTC values first, before doing the datediff operation.Here's an example:select datediff(day, cast('2010-01-01T12:34:56+13:00' as datetimeoffset(0)), cast('2010-01-01T12:34:56+08:00' as datetimeoffset(0) ) )-- Result is 1, not 0.Notice that the date values and time values are the same, but the offset is different. These translates to different days in UTC (2009-12-31 and 2010-01-01).This is inconsistent wi

Viewing all articles
Browse latest Browse all 12198

Trending Articles