You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Kurz Wolfgang <wo...@gwvs.de> on 2009/02/25 14:59:11 UTC

Problem with Date Comparisons

Hello everyone, 

I am having trouble searching for Content before or after a certain date in my Repository.

I have a attribute in my repository that's called "wiedervorlageAsDate" which is a Calendar Type.

Now when I do a Search on my Repository like the following:

I always get a full result-set when I use <= xs:dateTime or < and I always get a empty resultset when ever is use >= or > 

Somehow it doesn't matter at all what the value I compare to is.

This is the query I am using:
/jcr:root/*/*/*[(@artikelDokument = 'false') and (@freigegeben = 'true') and (@aktiv = 'true') and (@wiedervorlageAsDate <= xs:dateTime('2008-02-25T14:18:26.516+01:00'))and (@tempContent = 'false')]/*//element(*, nt:unstructured) [(@menuid = '1067') and  ( @ocm_classname='de.gwvs.tos.commons.jackrabbit.domain.JCRMenuId')]

Anyone have an idea on what I am doing wrong?

There has to be a solution cause I can't imagine any use of jackrabbit if you can't compare dates that are stored inside.

Would be awesome if anyone had some hints for me!

Thx a lot in advance!

Wolfgang

Re: Problem with Date Comparisons

Posted by Alexander Klimetschek <ak...@day.com>.
On Wed, Feb 25, 2009 at 2:59 PM, Kurz Wolfgang <wo...@gwvs.de> wrote:
> I always get a full result-set when I use <= xs:dateTime or < and I always get a empty resultset when ever is use >= or >
>
> Somehow it doesn't matter at all what the value I compare to is.
>
> This is the query I am using:
> /jcr:root/*/*/*[(@artikelDokument = 'false') and (@freigegeben = 'true') and (@aktiv = 'true') and (@wiedervorlageAsDate <= xs:dateTime('2008-02-25T14:18:26.516+01:00'))and (@tempContent = 'false')]/*//element(*, nt:unstructured) [(@menuid = '1067') and  ( @ocm_classname='de.gwvs.tos.commons.jackrabbit.domain.JCRMenuId')]
>
> Anyone have an idea on what I am doing wrong?

No idea yet. Did you check the field is actually stored as DATE
property? What values are stored in those dates (it could be that they
actually are all before the date given in your query....)?

When you mention "<=", "<", ">=" and ">", do you mean you always used
the xs:dateTime() function for the comparison?

You have to use that function for comparing to dates and it must
always include the full ISO8601 string (date + "T" + time +
"Z"/offset), but your query above looks good in this respect.

Reards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com