Description
The functx:total-months-from-duration function returns the total number of months in $duration . This function is different from the built-in fn:months-from-duration function because the latter will normalize the value and only give you the remainder number of months between 1 and 12. For example, fn:months-from-duration(xs:yearMonthDuration("P18M")) will return 6 , while functx:total-months-from-duration(xs:yearMonthDuration("P18M")) will return 18 . If $duration is the empty sequence, the empty sequence is returned.
Arguments and Return TypeName | Type | Description |
$duration |
xs:yearMonthDuration? |
the duration |
return value |
xs:decimal? |
XSLT Function DeclarationSee XQuery definition. | <xsl:function name="functx:total-months-from-duration" as="xs:decimal?"
xmlns:functx="http://www.functx.com">
<xsl:param name="duration" as="xs:yearMonthDuration?"/>
<xsl:sequence select="
$duration div xs:yearMonthDuration('P1M')
"/>
</xsl:function>
|
ExamplesXPath Example | Results |
---|
functx:total-months-from-duration(
xs:yearMonthDuration('P18M')) |
18 |
functx:total-months-from-duration(
xs:yearMonthDuration('P1Y')) |
12 |
functx:total-months-from-duration(
xs:yearMonthDuration('P1Y6M')) |
18 |
See AlsoHistory |
Recommended Reading:
|