days-from-duration

The number of days in a duration

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.

Parameters

Description

arg:numeric()

Examples

XPath

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 Also