Fetching Data based on Datatime field in MS CRM 2011 plugin

If you are looking for the code to retrieve data based on Datetime field you can use below code

private EntityCollection RetrieveData(DateTime _Date,IOrganizationService _iService)

        {

 QueryExpression _Query = new QueryExpressio{

    EntityName = “EntityName”, //Replace with entityname

    ColumnSet = new ColumnSet(“AttributeName”), //list of fields

         Criteria =

              {

              FilterOperator = LogicalOperator.And,

              Conditions =

                  {

                new ConditionExpression

                {

                 AttributeName=”_issuedate”, //Replace Condition attribute name

                 Operator=ConditionOperator.Equal,

                  Values={_Date } //Replace condition value

 

                 }

                  }

               }

 

           };

         EntityCollection _Entities = _iService.RetrieveMultiple(_Query);

Return _Entities;

}

 Enjoy !!!

 

Leave a Reply

Your email address will not be published. Required fields are marked *