Friday, February 14, 2014

Retrieve CRM records filter by time

1) DateTime theDate = new DateTime(2014, 1, 20, 10 , 0, 0);
var filter = new FilterExpression { FilterOperator = LogicalOperator.And };
filter.AddCondition(new ConditionExpression("modifiedon", ConditionOperator.OnOrAfter, theDate.ToUniversalTime())); 

This will retrieve records modified on or after Jan 20, 2014 0:0:0 that includes modified before 10'o clock.
OnOrAfter consider only date not time

2)
DateTime theDate = new DateTime(2014,1,20,10,0,0);
var filter = new FilterExpression { FilterOperator = LogicalOperator.And };
filter.AddCondition(new ConditionExpression("modifiedon", ConditionOperator.GreaterThan, theDate.ToUniversalTime()));

This will retrieve records modified only after Jan 20, 2014 10 o'clock


No comments:

Post a Comment