CRM OnOrAfter OnOrBefore ignore time component
As you know, under the hood there's no just date data in CRM.
When searching by DateTime fields in CRM, the operators on-or-after
and on-or-before
will ignore the time component of your query and will just search by date. Advanced find doesn't give you a lot to work with in this regard.
To get around this, you should use the between
operator.
You can use between both in FetchXML and QueryExpressions in C#:
var betweenCondition = new ConditionExpression("datefieldname", ConditionOperator.Between, lower, upper);
<filter type="or" >
<condition attribute="datefieldname" operator="between" >
<value>
2015-10-14T17:27:00+03:00
</value>
<value>
2015-10-22T12:48:00+03:00
</value>
</condition>
</filter>
Keep in mind that CRM stores dates in UTC, provide your datetimes accordingly in FetchXml.