cancel
Showing results for 
Search instead for 
Did you mean: 

XPath Date compare does not work

rajakari
Champ in-the-making
Champ in-the-making
I can't get date comparisions to work when making XPath queries.

Only this works:

          Query query = queryManager.createQuery("/jcr:root/app:company_home/cm:MCP/element(*, mcp:document)"
                                     + "[@cm:created = '2008-11-19T13:40:48.800+02:00']", Query.XPATH);
                                        
It returns the Node whose cm:created is the same as given date.

But if I change the comparator operator from '=' to '<' (or '>' or '<=' or '>='), it does not return a single Node.

Is this an unimplemented feature, or am I missing something in the query?
I believe this is a vital feature when using XPath.

I'm running this on alfresco-labs-sdk-3b.
4 REPLIES 4

mikeh
Star Contributor
Star Contributor

rajakari
Champ in-the-making
Champ in-the-making
I believe the example in the link is valid for Lucene:  @test\:date:[2003\-12\-16T00:00:00 TO 2003\-12\-17T00:00:00]

After several tries I can't figure out what it should be for XPath, this does not work: [@cm:created = '2001-01-01T00:00:00.000+02:00' to '2009-12-31T13:40:48.800+02:00']
It gives XPathSyntaxException.

Could somebody show me the way to do it?

amit_wmw
Champ in-the-making
Champ in-the-making
Hello,

I have a very basic question related to the above query: How to know/retrive exact time of node created? I can find year-month-date-hr-min but not beyond that. What is the meaning of 48.800+02:00 in the below query and how can I get it for my contents? Please suggest.

[@cm:created = '2008-11-19T13:40:48.800+02:00']

Also, if anybody has found the solution for comparing dates in XPATH using <=, >= kindly share that as well.

Thanks
Amit.

kpdamm
Champ in-the-making
Champ in-the-making
I believe this is a time stamp: 2008-11-19T13:40:48.800+02:00
Which correlates to November 19th, 2008, 1PM, 40 minutes, 48 seconds, and 800 microseconds with a GMT offset of two hours.