Returns the number of years in a duration.
fn:years-from-duration
( $arg
as xs:duration?
xs:integer?
If $arg
is the empty sequence, the function returns the empty sequence.
Otherwise, the function returns an xs:integer
representing the years
component in the value of $arg
. Given that a duration
is a ($months, $seconds)
tuple, the result is the value of ($months idiv 12)
.
If $arg
is a negative duration then the result will be negative.
If $arg
is an xs:dayTimeDuration
the function returns 0.
The expression fn:years-from-duration(xs:yearMonthDuration("P20Y15M"))
returns 21
.
The expression fn:years-from-duration(xs:yearMonthDuration("-P15M"))
returns -1
.
The expression fn:years-from-duration(xs:dayTimeDuration("-P2DT15H"))
returns 0
.