home contribute faq download

FunctX XQuery Functions

functx:date

Construct a date from a year, month and day

Google
Webxqueryfunctions.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

XQuery Function Declaration

See XSLT definition.
declare namespace functx = "http://www.functx.com";
declare function functx:date
  ( $year as xs:anyAtomicType ,
    $month as xs:anyAtomicType ,
    $day as xs:anyAtomicType )  as xs:date {

   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)))
 } ;

Examples

XQuery 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
Datypic XQuery Services

Recommended Reading:

XQuery