I have a business requirement to fetch Components based on a Schema from broker database on the basis of two date fields in metadata: start_date and end_date.

I will have one date input and the query should only return Components where this specific date lies between the values in the start_date and end_date metadata fields.

I tried with MetaValueCriteria and CustomDateRangeCriteria but was not successful.

Do we need to pass a specific date format to query on date fields and how can I use MetaValueCriteria with date fields?

  • Have you tried something already? Is there something that didn't work as you expected? Jan 9, 2017 at 12:25

1 Answer 1


Your question doesn't specify version or whether you're using .Net or Java but the API is similar. I quickly wrote this example to show you how I'd use the 2013 SP1 .Net Content Delivery API for a query like what you describe.

var inputDate = DateTime.Now;
var schemaId = 500;

var greaterThanStartDateCriteria = new CustomMetaKeyCriteria("start_date", Criteria.GreaterThanOrEqual);
var lessThanEndDateCriteria = new CustomMetaKeyCriteria("end_date", Criteria.LessThanOrEqual);

var startDateCriteria = new CustomMetaValueCriteria(greaterThanStartDateCriteria, inputDate);
var endDateCriteria = new CustomMetaValueCriteria(lessThanEndDateCriteria, inputDate);

var schemaCriteria = new ItemSchemaCriteria(schemaId);

var combinedCriteria = new AndCriteria(new Criteria[] { schemaCriteria, startDateCriteria, endDateCriteria });
var query = new Query(combinedCriteria);

var results = query.ExecuteQuery();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.