Putting current date through IQuery

Hi,
I am trying to build a query in Agile to fetch the items that are released in last 7 days. 

IQuery query = (IQuery)session.createObject(IQuery.OBJECT_TYPE,”SELECT ” +
“[Title Block.Number]” +
“FROM ” +
“[Items] ” +
“WHERE ” +
“[Title Block.Rev Release Date] >= DATE -7”); geeting syntax error at the place of DATE -7. Can anyone please help.

Thanks!
-Nagma

Agile Talent Asked on September 9, 2016 in Other APIs,   Software Development Kit (API).
Add Comment
3 Answer(s)

Hi Nagma,

 

Can you please explain these lines. What exactly happening at these statements.

 

Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -7);
Date dateToUse= cal.getTime();

IQuery query = (IQuery)session.createObject(IQuery.OBJECT_TYPE,”Select [Title Block.Number] FROM [Items] where [Title Block.Rev Release Date] >= %1″);
query.setParams(new Object[]{dateToUse});

 

– Thanks in advance

Agile User Answered on May 14, 2023.
Add Comment

the Date is not a valid field to be passed. at least you can use $TODAY as parameter to get the today date and put it to the query.
The problem is that via SDK is not possible to use $TODAY-7 because it will generate further syntax error.
To do that, you have to create custom Date field using JAVA and retrieve last 7 days as below:

Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -7);
Date dateToUse= cal.getTime();

IQuery query = (IQuery)session.createObject(IQuery.OBJECT_TYPE,”Select [Title Block.Number] FROM [Items] where [Title Block.Rev Release Date] >= %1″);
query.setParams(new Object[]{dateToUse});
query.execute();

Agile Angel Answered on September 9, 2016.
Add Comment

Hi,

Thank you so much. It’s working now.

Agile Talent Answered on September 9, 2016.

you are welcome 🙂 

on September 9, 2016.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.