05-05-2017 06:20 AM
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.
06-09-2017 05:26 AM
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...
06-12-2017 04:10 AM
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.
06-12-2017 04:54 AM
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
06-12-2017 05:04 AM
OK that's why. Thank you Saimir for your help.
06-12-2017 05:08 AM
you're welcome
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.