Using max function with dates in xquery
Posted: Sat Nov 12, 2005 1:48 am
I am trying to find the maximum date in an xml file using xquery. I believe I shold be able to do so using the following.
however this error message occurs:
SystemID: null
Description: E Failure converting {1975-02-20} to a number
This code
produces the same message. Deleting the line
gets rid of the error. I cannot use variable in any way without causing the error. Can anyone explain what is wrong?
Regards,
Daron.
Code: Select all
declare namespace q2 = "http://daron.ryan.org/namespace/q2.html";
<younger_workers>
{
let $workers:= doc("q2.xml")//q2:workers
let $youngest :=xs:date(max($workers//q2:bdate))
return $youngest
}
</younger_workers>
SystemID: null
Description: E Failure converting {1975-02-20} to a number
This code
Code: Select all
declare namespace q2 = "http://daron.ryan.org/namespace/q2.html";
<younger_workers>
{
let $workers:= doc("q2.xml")//q2:workers
let $youngest :=xs:date(max($workers//q2:bdate))
let $copy := $youngest
return <blank></blank>
}
</younger_workers>
Code: Select all
let $copy := $youngest
gets rid of the error. I cannot use
Code: Select all
$youngest
Regards,
Daron.