Skip to content
This repository has been archived by the owner on Jun 18, 2020. It is now read-only.

Datetimeoffset strangeness #160

Closed
patriksimek opened this issue Mar 7, 2014 · 2 comments
Closed

Datetimeoffset strangeness #160

patriksimek opened this issue Mar 7, 2014 · 2 comments

Comments

@patriksimek
Copy link

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 }
}
@ilianMaD
Copy link

ilianMaD commented Dec 1, 2015

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

@patriksimek
Copy link
Author

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants