home contribute faq download

FunctX XQuery Functions

functx:dateTime

Construct a date/time from individual components

Google
Webxqueryfunctions.com

Description

The functx:dateTime function constructs an xs:dateTime value from arguments representing the year, month, day, hour, minute and second. The arguments can have any type that can be cast to xs:integer. If the combination does not result in a valid time (e.g. the day is 32 or the minute is 61), an error is raised. The function does not currently support decimal numbers for $second.

Arguments and Return Type

NameTypeDescription
$year xs:anyAtomicType the year
$month xs:anyAtomicType the month
$day xs:anyAtomicType the day
$hour xs:anyAtomicType the hour
$minute xs:anyAtomicType the minute
$second xs:anyAtomicType the second
return value xs:dateTime

XQuery Function Declaration

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

   xs:dateTime(
     concat(functx:date($year,$month,$day),'T',
             functx:time($hour,$minute,$second)))
 } ;

Examples

XQuery ExampleResults
functx:dateTime(2006,6,12,20,6,12)
2006-06-12T20:06:12
functx:dateTime('2006','6','12','20','6','12')
2006-06-12T20:06:12

Depends On

functx:dateConstruct a date from a year, month and day
functx:timeConstruct a time from an hour, minute and second

See Also

functx:dateConstruct a date from a year, month and day
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