How to find the assets created since last run | Community
Skip to main content
Level 4
October 16, 2015
Solved

How to find the assets created since last run

  • October 16, 2015
  • 5 replies
  • 1146 views

My requirement is that my scheduled service will run at every 60 mins. I have done that.

Now I want to be able to find the assets created in last 60 minutes, I was writing a query for the same.So i created 

        DateTime dt = new DateTime();
        DateTime modified_last_run_date = dt.minusMinutes(60);
        DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ")

        String last_run_time =modified_last_run_date.toString(dtf);

    if I print the last_run_time string to console I get  --  "2015-08-19T17:38:36.221+0530"

However when I write Query :  SELECT p.* FROM [dam:Asset] AS p WHERE p.[jcr:created] >= CAST('2015-08-19T17:38:36.221+0530' AS DATE)  I get java.lang.IllegalArgumentException: Not a date string: 2015-08-19T17:38:36.221+0530

but if I write SELECT p.* FROM [dam:Asset] AS p WHERE p.[jcr:created] >= CAST('2015-08-19T17:38:36.221Z' AS DATE) I get no compilation error and query runs but with a lag of 5:30 hrs i mean i don't get correct results.

Can anybody suggest me solution.

In brief I want to find in each hourly run of my service which were the assets created since last run.

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 Lokesh_Shivalingaiah

as @siva mentioned, you need ':' to add in your time and your query should fetch you a result. You quickly try your query in 'tools -> query' in crxde

[img]Capture.JPG[/img]

5 replies

Siva_Sogalapalli
Community Advisor
Community Advisor
October 16, 2015

Did you try this SELECT p.* FROM [dam:Asset] AS p WHERE p.[jcr:created] >= CAST('2015-08-19T17:38:36.221+05:30' AS DATE)

smacdonald2008
Level 10
October 16, 2015

Try using the QueryBuilder API to perform this task - look at this older community thread - Justin give some advice 

https://forums.adobe.com/thread/1261774

Lokesh_Shivalingaiah
Lokesh_ShivalingaiahAccepted solution
Level 10
October 16, 2015

as @siva mentioned, you need ':' to add in your time and your query should fetch you a result. You quickly try your query in 'tools -> query' in crxde

[img]Capture.JPG[/img]

Kunal_Gaba_
October 16, 2015

To fix this, update your pattern string to "yyyy-MM-dd'T'HH:mm:ss.SSSXXX". 

Lokesh_Shivalingaiah
Level 10
October 16, 2015

and to get ':' use this format yyyy-MM-dd'T'HH:mm:ss.SSSZZ