DateTime Comparison

Can anyone tell me why when you run this query, you get the answer “$dt is a date time occurence AFTER $dtM” ?

Unless the world changed overnight, one would think that something that happened in the past is a smaller date? Hence a GMT of -5 hours would be an older date then the same datetime of GMT-0 hours.

The other conclusion I can reach is that this is a textual comparison, not a datetime comparison. In which case one would start questioning the usefulness of the xs:dateTime format in Tamino…

Also, is the behaviour the same for comparing xs:dateTime values contained in attributes? In nodes? What about when comparing to tf:getLastModified() ?

Thank you for your answers

XQUERY:
declare namespace xs = “XML Schema
let $dt := xs:dateTime(‘2004-05-24T14:12:30-05:00’)
let $dtM := xs:dateTime(‘2004-05-24T14:12:30-00:00’)
where $dt > $dtM
return
$dt is a date time occurence AFTER $dtM


Peter Endisch

---------------------------------------
I’m a Zen Garden Maintenance Engineer
---------------------------------------

Hi,

According to the XML Schema Part 2 document xs:dateTime(‘2004-05-24T14:12:30-05:00’) is five hours behind xs:dateTime(‘2004-05-24T14:12:30-00:00’). This means it is equal to
xs:dateTime(‘2004-05-24T19:12:30-00:00’). So, the result of the comparison xs:dateTime(‘2004-05-24T14:12:30-05:00’) > xs:dateTime(‘2004-05-24T14:12:30-00:00’) is “true”.

Kind Regards,
Thorsten

Hello Thorsten,

thank you for your reply.

I am rather confused though. I always thought that if something is behind, then you go counterclockwise, not clockwise.

Hence, it seems to me that:

xs:dateTime(‘2004-05-24T14:12:30-05:00’) = xs:dateTime(‘2004-05-24T09:12:30-00:00’)
and not xs:dateTime(‘2004-05-24T19:12:30-00:00’) as you have suggested.

As I am in north america, if it is noon at Greenwich in England, it will be 7am here (07:00) (5 hours behind), not 5pm (17:00) (5 hours ahead).


Peter Endisch

---------------------------------------
I’m a Zen Garden Maintenance Engineer
---------------------------------------

Hi Peter,

In order to compare two xs:dateTime values with a given timezone you have to normalize them to UTC. The value xs:dateTime(‘2004-05-24T14:12:30-05:00’) has a timezone specified by a negative offset to UTC. So you have to add the 5 hours to get the normalized UTC time which is xs:dateTime(‘2004-05-24T19:12:30-00:00’).
In your example you have to add 5 hours to your north american time before you can compare it with a Greenwich time.
Kind Regards,
Thorsten