Description
The functx:days-in-month function returns the number of days in the month of $date as an integer.
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 |
| return value |
xs:integer? |
XQuery Function Declaration| See XSLT definition. | | XQuery Syntax for January 2007 (1.0): |
|---|
declare namespace functx = "http://www.functx.com";
declare function functx:days-in-month
( $date as xs:anyAtomicType? ) as xs:integer? {
if (month-from-date(xs:date($date)) = 2 and
functx:is-leap-year($date))
then 29
else
(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
[month-from-date(xs:date($date))]
} ; | | XQuery Syntax for July 2004 - November 2005 (CR): |
|---|
declare namespace functx = "http://www.functx.com";
declare function functx:days-in-month
( $date as xdt:anyAtomicType? ) as xs:integer? {
if (month-from-date(xs:date($date)) = 2 and
functx:is-leap-year($date))
then 29
else
(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
[month-from-date(xs:date($date))]
} ; | | XQuery Syntax for May 2003: |
|---|
declare namespace functx = "http://www.functx.com"
define function days-in-month
( $date as xdt:anyAtomicType? ) as xs:integer? {
if (fn:get-month-from-date(xs:date($date)) = 2 and
functx:is-leap-year($date))
then 29
else
(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
[fn:get-month-from-date(xs:date($date))]
} |
Examples| XQuery Example | Results |
|---|
functx:days-in-month(xs:date('2004-01-23'))
|
31
|
functx:days-in-month(
xs:dateTime('2004-02-15T12:00:13'))
|
29
|
functx:days-in-month('2005-02-15')
|
28
|
Depends OnSee AlsoHistory |
|