home contribute faq download

FunctX XSLT Functions

functx:days-in-month

Number of days in the month

Google
Webxsltfunctions.com

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

NameTypeDescription
$date xs:anyAtomicType? the date
return value xs:integer?

XSLT Function Declaration

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

  <xsl:sequence select="
   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))]
 "/>

</xsl:function>

Examples

XPath ExampleResults
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 On

functx:is-leap-yearWhether a date falls in a leap year

See Also

functx:last-day-of-monthThe last day of the month of a date

History

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

Recommended Reading:

XQuery