'Xslt or Xquery to test the time difference less than hours
I am new to xquery and xslt. So i was able to get the time difference in a variable in this format by using fn:current-datetime- xs:datetime().
The output is P11DT2H2M20.404S
But now my question is: Is there any function to calculate the Hours are less than 24 hours or how can I get find out its less than 24 hours?
I can use substring after T and then compare with 24 hours but wanted to know if there is a better way.
Solution 1:[1]
You can divide one duration by another e.g. xs:dayTimeDuration('P11DT2H2M20.404S') div xs:dayTimeDuration('PT24H') divides by 24 hours and if that result is less than 1 than the (original) duration is less than 24 hours.
Solution 2:[2]
You can simply do
`if ($myDuration lt xs:dayTimeDuration('PT24H')) ...`
which seems more direct than Martin's solution.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Martin Honnen |
| Solution 2 | Michael Kay |
