1

How can I convert Strings in this format dd/mm/yyyy hh:mm:ss into this format yyyy/mm/dd hh:mm:ss using XPAth 1.0?

dirkk
  • 6,160
  • 5
  • 33
  • 51
D. Caan
  • 1,907
  • 6
  • 22
  • 36
  • 1
    FYI: There is an prescribed XML date & time format. The author of this XML file should be using that. http://stackoverflow.com/questions/254753/ – Moby Disk Jul 17 '14 at 17:57

1 Answers1

2

Unfortunately, XPath 1.0 does not even support regular expression. Hence, I think you are stuck with using substring functions.

The following is not very elegeant, but it should work ($date being your input string). It split the different parts and reconstruct the string afterwards.

concat(
  substring-after(substring-after(substring-before($date, ' '), '/'), '/'),
  '/',
  substring-before(substring-after(substring-before($date, ' '), '/'), '/'),
  '/',
  substring-before(substring-before($date, ' '), '/'),
  ' ',
  substring-after($date, ' ')
)
dirkk
  • 6,160
  • 5
  • 33
  • 51