The months() Function

Release 2.0 - ...

Syntax

  CopyCode image Copy Code
number months(string)

Description

This function returns a whole number of months, according to the following rules:

  • If the string parameter represents a legal lexical xsd:duration, the return value is equal to the number specified in the months component plus 12 * the number specified in the years component. The sign of the result will match the sign of the duration. Day, hour, minute, and second components, if present, are ignored. Any other input parameter causes a return value of NaN.

Example

XML CopyCode image Copy Code
<xforms:output value="months('P1Y2M')">
   <xforms:label>Result : </xforms:label>
</xforms:output>

The above example returns "14".

Specification

Link to the XForms specification: the months() function.