functx:total-months-from-duration
The total number of months in a yearMonthDuration
Description
The functx:total-months-from-duration function returns the total number of months in $duration. This function is different from the built-in fn:months-from-duration function because the latter will normalize the value and only give you the remainder number of months between 1 and 12. For example, fn:months-from-duration(xs:yearMonthDuration(“P18M”)) will return 6, while functx:total-months-from-duration(xs:yearMonthDuration(“P18M”)) will return 18. If $duration is the empty sequence, the empty sequence is returned.
Parameters |
Description |
---|---|
duration:time() |
the duration |
Examples
XPath |
Results |
---|---|
functx:total-months-from-duration(xs:yearMonthDuration(‘P18M’)) |
18 |
functx:total-months-from-duration(xs:yearMonthDuration(‘P1Y’)) |
12 |
functx:total-months-from-duration(xs:yearMonthDuration(‘P1Y6M’)) |
18 |