I want to convert the 31-DEC-2016 i.e., dd-mmm-yyyy to yyyy-mm-dd in the XSLT using format-dateTime function but the output is not as expected.Can anyone help on this?
You cannot use the format-dateTime()
function on a string that is not a valid dateTime (or the format-date()
function on a string that is not a valid date). You need to process the string using string functions first.
Try:
Calling this template with a datestring parameter of "31-DEC-2016" will return a value of "2016-12-31".
Example of call (mostly guessing, not having seen the input):
In XSLT 2.0, you can define a function instead of a named template. The following stylesheet:
XSLT 2.0
will return:
2016-03-09