Search code examples
xsltxslt-1.0xquery

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

  • 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.