home contribute faq download

FunctX XSLT Functions

functx:date

Construct a date from a year, month and day

Google
Webxsltfunctions.com

Description

The functx:date function constructs an xs:date value from arguments representing the year, month and day. The arguments can have any type that can be cast to xs:integer. If the combination does not result in a valid date (e.g. the day is 32 or the month is 13), an error is raised.

Arguments and Return Type

NameTypeDescription
$year xs:anyAtomicType the year
$month xs:anyAtomicType the month
$day xs:anyAtomicType the day
return value xs:date

XSLT Function Declaration

See XQuery definition.
XSLT 2.0 Syntax:
<xsl:function name="functx:date" as="xs:date"
              xmlns:functx="http://www.functx.com" >
  <xsl:param name="year" as="xs:anyAtomicType"/>
  <xsl:param name="month" as="xs:anyAtomicType"/>
  <xsl:param name="day" as="xs:anyAtomicType"/>

  <xsl:sequence select="
   xs:date(
     concat(
       functx:pad-integer-to-length(xs:integer($year),4),'-',
       functx:pad-integer-to-length(xs:integer($month),2),'-',
       functx:pad-integer-to-length(xs:integer($day),2)))
 "/>

</xsl:function>

Examples

XSLT ExampleResults
functx:date(2006,6,12)
2006-06-12
functx:date('2006','06','12')
2006-06-12

Depends On

functx:pad-integer-to-lengthPads an integer to a desired length by adding leading zeros

See Also

functx:timeConstruct a time from an hour, minute and second

History

Published OnLast UpdatedContributor(s)
2006-08-222007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, http://www.datypic.com
Need XSLT Help?
D A T Y P I C
Training | Consulting | Development

XQuery by Priscilla WalmsleyGet the book!
XQuery by Priscilla Walmsley