Datetimeoffset strangeness
patriksimek opened this issue · comments
Consider this TSQL code:
if convert(datetimeoffset(7), '2014-02-14 22:59:59.9999999 +05:00') = convert(datetimeoffset(7), '2014-02-14 17:59:59.9999999 +00:00')
print 'EQUAL'
Dates are equal, but this simple query ...
select convert(datetimeoffset(7), '2014-02-14 22:59:59.9999999 +05:00') as dto1, convert(datetimeoffset(7), '2014-02-14 17:59:59.9999999 +00:00') as dto2
... returns this ...
{
dto1: { Sat, 15 Feb 2014 03:59:59 GMT nanosecondsDelta: 0.0009999 },
dto2: { Fri, 14 Feb 2014 17:59:59 GMT nanosecondsDelta: 0.0009999 }
}
Hi, if I see it right you have 22 o'clock + 5 hours to equals 17 o'clock, may be it should be like that:
select convert(datetimeoffset(7), '2014-02-14 22:59:59.9999999 +00:00') as dto1, convert(datetimeoffset(7), '2014-02-14 17:59:59.9999999 +05:00') as dto2
select datediff(second, '1970-01-01', '2014-02-14 22:59:59.9999999 +05:00')
Returns number 1392400799
which is unix timestamp for Fri, 14 Feb 2014 17:59:59 GMT
.