cancel
Showing results for 
Search instead for 
Did you mean: 

MDM java api search with DateSearchConstraint on Timestamp mdm fields

Former Member
0 Kudos

Hi MDMAPI experts,

I was trying to retrieve a timestamp field with a certain date and not able to successfully, is it because of GMT or Timestamp field. Could you post any samples if you have.

Calendar calYesday = Calendar.getInstance();

calYesday.set(2010,11,29);

FieldSearchDimension fsdULILastTimeIncluded = new FieldSearchDimension(new FieldId(repSchema.getFieldId("Customers", "last_updated")));

DateTimeSearchConstraint srchConstCreateLE = new DateTimeSearchConstraint(calToday, DateTimeSearchConstraint.EQUALS);

Please let me know.

Thanks

-Sai

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Specify GMT+00:00 timezone in calendar

Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
Former Member
0 Kudos

Hi,

Use below code to search records based on timestamp constraint

Search search = new Search(mainTableId);		
SearchGroup sg1 = new SearchGroup();

FieldId updateDateField = schema.getTableSchema(mainTableId).getFieldId("MDM_UPDATE_DATE"); 
Calendar upperLimit = Calendar.getInstance();
Calendar lowerLimit = Calendar.getInstance();
lowerLimit.clear(Calendar.HOUR);
lowerLimit.clear(Calendar.HOUR_OF_DAY);
lowerLimit.clear(Calendar.MINUTE);
lowerLimit.clear(Calendar.SECOND);
lowerLimit.clear(Calendar.MILLISECOND);

FieldSearchDimension fsdUpdateDate = new FieldSearchDimension(updateDateField);
DateTimeSearchConstraint dtscUpdateDateUpper = new DateTimeSearchConstraint(upperLimit,DateTimeSearchConstraint.LESS_THAN_OR_EQUAL_TO);
sg1.addSearchItem(fsdUpdateDate, dtscUpdateDateUpper);

DateTimeSearchConstraint dtscUpdateDateLower = new DateTimeSearchConstraint(lowerLimit,DateTimeSearchConstraint.GREATER_THAN_OR_EQUAL_TO);
sg1.addSearchItem(fsdUpdateDate, dtscUpdateDateLower);

sg1.setComparisonOperator(SearchGroup.AND_OPERATOR);

search.addSearchItem(sg1);

RetrieveLimitedRecordsCommand retrieveLimitedRecordsCommand = new RetrieveLimitedRecordsCommand(connections);
retrieveLimitedRecordsCommand.setSession(userSessionID);	
retrieveLimitedRecordsCommand.setResultDefinition(resultDefinition);
retrieveLimitedRecordsCommand.setSearch(search);		
retrieveLimitedRecordsCommand.execute();

Regards,

Amol

mf_haq
Active Participant
0 Kudos

Hi,

Please follow the below link...hope its clear you.

Mercy

MFH

Former Member
0 Kudos

Hi MFH,

Thanks for the response, but this search is not successful may be because of timestamp field. Does it compare with GMT internally, I dont know. I was trying to compare Timestamp field less than today (so I hardcoded it Calendar(year-2011, month-01, yesterday 14) and it wont get results properly.

Please let me know of or share more info on this.

Thanks

-Sai