cancel
Showing results for 
Search instead for 
Did you mean: 

Using CurrentDate in NXQL

Thierry_SEBBAR
Champ in-the-making
Champ in-the-making

Hi!

In Nuxeo 6.0 HF 38 I'm trying to use CurrentDate in NXQL in avanced search or by quering http://nuxeoserver/nuxeo/api/v1/query

When I try this, it works: http://nuxeoserver/nuxeo/api/v1/query?query=SELECT * FROM Document WHERE dc:created > TIMESTAMP '2017-04-04 00:00:00'

But this doesn't work : http://nuxeoserver/nuxeo/api/v1/query?query=SELECT * FROM Document WHERE dc:created > TIMESTAMP '@{CurrentDate.days(-1).format("yyyy-MM-dd HH:mm:ss")}'

I get this error : {"entity-type":"exception","code":"org.nuxeo.ecm.webengine.WebException","status":400,"message":"Failed to execute query: java.lang.IllegalArgumentException: Invalid format: "@{CurrentDate.days(-1).format("y..." in query: SELECT * FROM Document WHERE dc:created > TIMESTAMP '@{CurrentDate.days(-1).format("yyyy-MM-dd HH:mm:ss")}'"}

Thanks for help.

5 REPLIES 5

00000001_
Confirmed Champ
Confirmed Champ

Hi, did you try: "SELECT * FROM Document WHERE dc:created <= DATE '@{CurrentDate.format("yyyy-MM-dd HH:mm:ss")}'"

Or you can have a look to https://answers.nuxeo.com/general/q/23699bc926634b439b552c3848e12ad1/How-do-I-pass-a-date-relative-t...

Thierry_SEBBAR
Champ in-the-making
Champ in-the-making

Hi Saimir,

With this : http://nuxeoserver/nuxeo/api/v1/query?query=SELECT * FROM Document WHERE dc:created <= DATE '@{CurrentDate.days(-1).format(“yyyy-MM-dd HH:mm:ss”)}'

I got the same error : {"entity-type":"exception","code":"org.nuxeo.ecm.webengine.WebException","status":400,"message":"Failed to execute query: java.lang.IllegalArgumentException: Invalid format: "@{CurrentDate.days(-1).format(“y..." in query: SELECT * FROM Document WHERE dc:created > DATE '@{CurrentDate.days(-1).format(“yyyy-MM-dd HH:mm:ss”)}'"}

When I use this query (the same in my first question) in an automation chain it works : SELECT * FROM Document WHERE dc:created > TIMESTAMP '@{CurrentDate.days(-1).format(“yyyy-MM-dd HH:mm:ss”)}'

but it dosen't work in the API Url nor in NSQL Advanced search.

Thank you.

Hi, You can't access mvel ( "@{CurrentDate.days(-1)") function here because at this point it is out of context. I suggest You to build some client code witch will call the rest service

OK that's why. Thank you Saimir for your help.

you're welcome

Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.