Expand my Community achievements bar.

SOLVED

QueryBuilder 1_relativedaterange based string operation

Avatar

Former Community Member

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?

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

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.

View solution in original post

2 Replies

Avatar

Level 10

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.

Avatar

Correct answer by
Former Community Member

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.

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----