xf:get-years-from-yearMonthDuration

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.

Signatures

xf:get-years-from-yearMonthDuration(xf:yearMonthDuration? $yearMonthDuration-var) —> xs:integer?

Arguments

Data Type
Argument
Description

xf:yearMonthDuration?

$yearMonthDuration-var

Contains a representation of a time duration which can contain years and months.

Returns

Returns the number of year as an integer from years component of $yearMonthDuration-var.

Examples

Get Years from yearMonthDuration with Years and Months

<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).

Get Years from yearMonthDuration with Just Negative Years

<years>{xf:get-years-from-yearMonthDuration(xf:yearMonthDuration("-P5Y"))}</years> 

The preceding query generates the following result:

<years>-5</years> 

Get Years from yearMonthDuration with Just Months

<years>{xf:get-years-from-yearMonthDuration(xf:yearMonthDuration("P10M"))}</years> 

The preceding query generates the following result:

<years>0</years> 

Related Topics

W3C get-years-from-yearMonthDuration function description.

W3C yearMonthDuration data type description.