[xquery-talk] Date Arithmetic
xfranc at online.fr
Fri Oct 3 00:01:03 PDT 2003
The current XML Query specifications define a '-' operator on dates,
yielding a result of type xdt:dayTimeDuration.
From this thing you can in principle extract a number of days
or months, but this is neither very easy nor very clear.
To the best of my knowledge, no current XML Query engine
actually implements these specifications.
However, my own implementation (Qizx/open), which is dissident
wrt the specs in this respect, provides exactly what you want:
the difference of two dates yields a number of days as an integer.
the difference of two dateTimes yields a number of seconds as a double.
There is apparently a move towards more sensible specifications
inited by Michael Kay.
Note: dates must be specified according to ISO 8601 standard:
10-31-2003 should be written 2003-10-31 [ precisely: xs:date("2003-10-31") ]
More information about the talk