Search code examples
stringdatexsltxslt-2.0

How to parse string to date in xslt 2.0


Is it possible to convert strings like 30042013 (30 April 2013) to a date format?

So I can use it later in functions like format-date


Solution

  • fn:dateTime($arg1 as xs:date?, $arg2 as xs:time?) will convert its arguments to xs:dateTime.

    Just use fn:substring() and fn:concat() to cut out the relevant parts and join them as yyyy-mm-dd before passing that to fn:dateTime.