Extracts the number of years from the years component of $yearMonthDuration-var.
If the value of $yearMonthDuration-var is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items (), which is similar to null in SQL.
xf:get-years-from-yearMonthDuration(xf:yearMonthDuration? $yearMonthDuration-var) —> xs:integer?
Contains a representation of a time duration which can contain years and months. |
Returns the number of year as an integer from years component of $yearMonthDuration-var.
<years>{xf:get-years-from-yearMonthDuration(xf:yearMonthDuration("P2Y13M"))}</years>
The preceding query generates the following result:
<years>2</years>
Note: Even though 13 months is specified in the month component (13M) of the yearMonthDuration creation string (adding up to an additional year), only 2 years is returned as originally specified by the years component (2Y).
<years>{xf:get-years-from-yearMonthDuration(xf:yearMonthDuration("-P5Y"))}</years>
The preceding query generates the following result:
<years>-5</years>
<years>{xf:get-years-from-yearMonthDuration(xf:yearMonthDuration("P10M"))}</years>
The preceding query generates the following result:
<years>0</years>
W3C get-years-from-yearMonthDuration function description.
W3C yearMonthDuration data type description.