XPath query for date ranges

You can set the appropriate Xpath query string with the exact date range values to filter the records between. In Xpath Queries, you don’t need to convert any date values to UniversalTime because you are using the Xpath query string of the Thing types.

The below sample code will return all blood pressure items added between July 1st, 2010 and July 14th, 2010:

HealthRecordSearcher searcher = PersonInfo.SelectedRecord.CreateSearcher();

HealthRecordFilter filter = new HealthRecordFilter(BloodPressure.TypeId);

filter.XPath = "/thing/data-xml/blood-pressure/when/date[y=2009 and m=7 and d>1 and d<=14]";

// y represents year, m represents month and d represents date.

searcher.Filters.Add(filter);

HealthRecordItemCollection items = searcher.GetMatchingItems()[0];