cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

need Query Spec to get objects modified Today or on a particular date.

vuchekar
9-Granite

need Query Spec to get objects modified Today or on a particular date.

Hi,

i want to fetch modified object list for particular date or today.

i tried to use below Query, but it wont give me results.

please point out my mistake in below query.

any help will be grate.

=================

DateFormat dateFormat1 = new SimpleDateFormat("dd/MM/yyyy");

  java.util.Date date1 = dateFormat1.parse("12/01/2015");

  long time1 = date1.getTime();

  Timestamp ts1= new Timestamp(time1);

  criteria.appendWhere(new SearchCondition(WTPart.class,"thePersistInfo.modifyStamp", SearchCondition.EQUAL, ts1), new int[] {0});

  criteria.appendAnd();

  criteria.appendWhere(new SearchCondition(WTPart.class, "iterationInfo.latest", "TRUE"));

  QueryResult qr= PersistenceHelper.manager.find(criteria);

  System.out.println("Query Size = "+qr.size());

=======================

Regards,

Vivek

1 REPLY 1
BhushanNehe
14-Alexandrite
(To:vuchekar)

Hi Vivek,

Try passing a date range instead of a particular timestamp. You can print the criteria object to see how the query is built.

long time2 = date2.getTime();

  Timestamp ts2= new Timestamp(time2);

  criteria.appendWhere(new SearchCondition(WTPart.class,"thePersistInfo.modifyStamp", SearchCondition.GREATER_THAN_OR_EQUAL, ts1), new int[] {0});

  criteria.appendAnd();

  criteria.appendWhere(new SearchCondition(WTPart.class,"thePersistInfo.modifyStamp", SearchCondition.LESS_THAN_OR_EQUAL, ts2), new int[] {0});

Regards,

Bhushan

Top Tags