Description
The fn:days-from-duration function calculates the total number of whole days in a normalized xs:duration value. This is not necessarily the same as the integer that appears before the D in the value. For example, if the duration is P1DT36H , the function returns 2 rather than 1. This is because 36 hours is equal to 1.5 days, and the normalized value is therefore P2DT12H .
This function does not round the number of days; if the duration is 2 days and 23 hours, it returns the integer 2.
For a function that returns the total number of days as a decimal number, see functx:total-days-from-duration.
This description is © Copyright 2007, Priscilla Walmsley. It is excerpted from the book XQuery by Priscilla Walmsley, O'Reilly, 2007. For a complete explanation of this function, please refer to Appendix A of the book. Arguments and Return TypeName | Type |
$arg |
xs:duration? |
return value |
xs:integer? |
ExamplesXPath Example | Results |
---|
days-from-duration(
xs:dayTimeDuration('P5D')) |
5 |
days-from-duration(
xs:dayTimeDuration('-PT24H')) |
-1 |
days-from-duration(
xs:dayTimeDuration('PT23H')) |
0 |
days-from-duration(
xs:dayTimeDuration('P1DT36H')) |
2 |
days-from-duration(
xs:dayTimeDuration('PT1440M')) |
1 |
See AlsoHistory |
Recommended Reading:
|