Description
The functx:mmddyyyy-to-date function converts $dateString into a valid xs:date value. The order of the digits in $dateString must be MMDDYYYY, but it can contain any (or no) delimiters between the digits.
Arguments and Return Type| Name | Type | Description |
$dateString |
xs:string? |
the MMDDYYYY string |
| return value |
xs:date? |
XQuery Function Declaration| See XSLT definition. | | XQuery Syntax for July 2004 - January 2007 (1.0): |
|---|
declare namespace functx = "http://www.functx.com";
declare function functx:mmddyyyy-to-date
( $dateString as xs:string? ) as xs:date? {
if (empty($dateString))
then ()
else if (not(matches($dateString,
'^\D*(\d{2})\D*(\d{2})\D*(\d{4})\D*$')))
then error(xs:QName('functx:Invalid_Date_Format'))
else xs:date(replace($dateString,
'^\D*(\d{2})\D*(\d{2})\D*(\d{4})\D*$',
'$3-$1-$2'))
} ; | | XQuery Syntax for May 2003: |
|---|
declare namespace functx = "http://www.functx.com"
define function mmddyyyy-to-date
( $dateString as xs:string? ) as xs:date? {
if (fn:empty($dateString))
then ()
else if (fn:not(fn:matches($dateString,
'^\D*(\d{2})\D*(\d{2})\D*(\d{4})\D*$')))
then fn:error(xs:QName('functx:Invalid_Date_Format'))
else xs:date(fn:replace($dateString,
'^\D*(\d{2})\D*(\d{2})\D*(\d{4})\D*$',
'$3-$1-$2'))
} |
Examples| XQuery Example | Results |
|---|
functx:mmddyyyy-to-date('12-15-2004')
|
2004-12-15
|
functx:mmddyyyy-to-date('12152004')
|
2004-12-15
|
functx:mmddyyyy-to-date('12/15/2004')
|
2004-12-15
|
History |
|