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 TypeName | Type | Description |
$dateString |
xs:string? |
the MMDDYYYY string |
return value |
xs:date? |
XSLT Function DeclarationSee XQuery definition. | <xsl:function name="functx:mmddyyyy-to-date" as="xs:date?"
xmlns:functx="http://www.functx.com">
<xsl:param name="dateString" as="xs:string?"/>
<xsl:sequence select="
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'))
"/>
</xsl:function>
|
ExamplesXPath 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 |
Recommended Reading:
|