Hello!
I have a little problem. In my XML-File I have a date in the following format: DD-MM-YYYY (i.e. 15-02-2005) and i would like to order the list after this date. The problem is, that flwor doesn´t recognize this date as a date, it does the sorting in the wrong way (it begins to sort after the day, not after the year, so 13-05-2007 is before 15-02-2005).
I tried to convert the date to a date the DB understands (YYYY-MM-DD), but the reverse()-function doesn´t accept the string which I have created with the replace()-function as a list, so at the end I have again 15-02-2005 instead of 2005-02-15.
Has somebody any idea how to convert the date or to convert the string to a list which can be used in the reverse()-function? Is it possible to do that in the “order by”-clause? Because this is dynamically generated.
Here is the code I use to get the elements from the DB:
<Items>
{let $item :=
for $p in collection("/db/bka/opu")//OP_OffenePunkte/OP_OffenerPunkt[@ID="ffa29eb7442ac0bdeceb8ab98f5f5e60"]/OP_Prozesse/OP_Prozess
order by replace(reverse((replace($p//OP_Datum, '-', ', '))), ', ', '-') descending
return $p,
$count := count($item),
$begin := 1,
$max := 5,
$end := if($count >= $max) then $max else $count
for $i in $begin to $end
let $cur := item-at($item, $i)
return
<Item>
<part>
{$cur/OP_Status}
<href>index.php?nav=p.offpkt.proz&proz={$cur/@ID}</href></part><part>
{$cur/OP_Datum}
<href></href></part>
</Item>}
</Items>
Thanks in advance,
Baerlie