QueryBuilder 1_relativedaterange based string operation | Community
Skip to main content
May 3, 2016
Solved

QueryBuilder 1_relativedaterange based string operation

  • May 3, 2016
  • 2 replies
  • 828 views

Hi,

The existing API on 1_relativedaterange for querybuilder is working fine if the associated properties is of the type Date.

I have a requirement to filter the nodes search based a field called end date which is of the data type String. 

Is there any method to cast a string to date and could it be used in query builder?

What works currently:

path=/content/abc/jcr:content/samplelist
p.hits=full
p.limit=-1
1_relativedaterange.property=jcr:created
1_relativedaterange.lowerBound=-6M

What is not working: always returns 0 even if there are list with that end date

path=/content/abc/jcr:content/samplelist
p.hits=full
p.limit=-1
1_relativedaterange.property=end_date
1_relativedaterange.lowerBound=-6M

Could you please assist or provide us suggestions on this?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by

Hi,

I formatted the string in the dialog using Format property and if the result is of the below mentioned format, then querybuilder is picking it.

eg: 2016-03-28T17:01:41.174-04:00

Thanks.

2 replies

smacdonald2008
Level 10
May 3, 2016

As you stated, QueryBuilder or JCR SQL uses date searches based on a Date prop values such as jcr:created. Date searches do not work on String values. There is no cast funtionaity. You would have to read the string prop value, manually cast in Java, and write back the cast date value to a date prop and then perform query.

Accepted solution
May 3, 2016

Hi,

I formatted the string in the dialog using Format property and if the result is of the below mentioned format, then querybuilder is picking it.

eg: 2016-03-28T17:01:41.174-04:00

Thanks.