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

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

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

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

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

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum! ______________________________ Check out the Windchill Tips Board! We're talking about Whirlpool's use of digital twin, augmented reality, and data-driven design!

The NAVIGATE WORKING GROUP is here! Come innovate with PTC!

Sign up for a Working Group