xf:get-months-from-yearMonthDuration

Extracts the number of months from the months 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-months-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 months as an integer from months component of $yearMonthDuration-var.

Examples

Get Months from yearMonthDuration with Years and Months

<months>{xf:get-months-from-yearMonthDuration(xf:yearMonthDuration("P2Y10M"))}</months> 

The preceding query generates the following result:

<months>10</months> 

Get Months from yearMonthDuration with Just Negative Months

<months>{xf:get-months-from-yearMonthDuration(xf:yearMonthDuration("-P5M"))}</months> 

The preceding query generates the following result:

<months>-5</months> 

Related Topics

W3C get-months-from-yearMonthDuration function description.

W3C yearMonthDuration data type description.