0

I am using XQuery 3.0 for exist-db, and am trying to make the string $value a dateTime object. This is what I've got, but it's not working:

let $value := '"2001-10-18T08:47:00"'

if ($key = 'start_time')
    then 
        element { $key } { xs:dateTime(string(replace($value, '"', ''))) }

It's saying: illegal lexical form for date-time-like value ''. Any ideas?

Stormdamage
  • 389
  • 1
  • 5
  • 16

1 Answers1

1

I'm unable to reproduce the error you're getting with that code - which is incomplete (lacks return and else clauses, doesn't define $key). But paring those issues away, your code runs fine for me, as follows:

let $value := '"2001-10-18T08:47:00"'
return
    xs:dateTime(replace($value, '"', ''))

The result:

2001-10-18T08:47:00
Joe Wicentowski
  • 5,159
  • 16
  • 26
  • You're right, the XQuery is fine. I managed to track it down to one iteration which has the $value as an empty string rather than a date. Thanks for your help! – Stormdamage Feb 08 '16 at 18:50