home contribute faq download

FunctX XSLT Functions

functx:add-months

Adds months to a date

Google
Webdatypic.com

Description

The functx:add-months function adds a specified number of months to a date. The $date argument must be castable to xs:date, meaning that it must have the type xs:date or xs:dateTime, or be an xs:string or untyped value of the form YYYY-MM-DD.

Arguments and Return Type

NameTypeDescription
$date xs:anyAtomicType? the date
$months xs:integer the number of months to add
return value xs:date?

XSLT Function Declaration

See XQuery definition.
<xsl:function name="functx:add-months" as="xs:date?"
              xmlns:functx="http://www.functx.com">
  <xsl:param name="date" as="xs:anyAtomicType?"/>
  <xsl:param name="months" as="xs:integer"/>

  <xsl:sequence select="
   xs:date($date) + functx:yearMonthDuration(0,$months)
 "/>

</xsl:function>

Examples

XPath ExampleResults
functx:add-months(xs:date('2004-01-23'),1)
2004-02-23
functx:add-months(
     xs:dateTime('2005-12-31T12:00:13'),2)
2006-02-28
functx:add-months('2005-12-31',-3)
2005-09-30

Depends On

functx:yearMonthDurationConstruct a yearMonthDuration from a number of years and months

See Also

functx:next-dayThe next day

History

Published OnLast UpdatedContributor(s)
2006-08-082007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, https://www.datypic.com
Datypic XSLT Services

Recommended Reading:

XQuery