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| Name | Type | Description |
$date |
xs:anyAtomicType? |
the date |
$months |
xs:integer |
the number of months to add |
| return value |
xs:date? |
XQuery Function Declaration| See XSLT definition. | | XQuery Syntax for January 2007 (1.0): |
|---|
declare namespace functx = "http://www.functx.com";
declare function functx:add-months
( $date as xs:anyAtomicType? ,
$months as xs:integer ) as xs:date? {
xs:date($date) + functx:yearMonthDuration(0,$months)
} ; | | XQuery Syntax for July 2004 - November 2005 (CR): |
|---|
declare namespace functx = "http://www.functx.com";
declare function functx:add-months
( $date as xdt:anyAtomicType? ,
$months as xs:integer ) as xs:date? {
xs:date($date) + functx:yearMonthDuration(0,$months)
} ; | | XQuery Syntax for May 2003: |
|---|
declare namespace functx = "http://www.functx.com"
define function add-months
( $date as xdt:anyAtomicType? ,
$months as xs:integer ) as xs:date? {
xs:date($date) + functx:yearMonthDuration(0,$months)
} |
Examples| XQuery Example | Results |
|---|
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 OnSee AlsoHistory |
|