0
votes

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?

1

1 Answers

1
votes

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