Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

linq query for CRM 2016 online filtering date filed to just date

$
0
0

Hi

I am trying to select a set of records from a customer entity called "new_title" where I have a custom date field "new_orderdate". I want to pull all the records where "new_orderdate" equals a specific date

XrmServiceContext orgContext = new XrmServiceContext("Xrm")

var _today = DateTime.Now.Date;

var orders = from x in orgContext.CreateQuery("new_title")
             where x.GetAttributeValue<string ("statecode") == "Active"
                                select x;

 this returns all the records from the title Entity.  I want to restrict to records only today's date.

 

However, I am unable to filter by where x.GetAttributeValue<DateTime>("new_orderdate").Date == _today

Note- I want to compare only the date portion omitting the time stamps.

I tried to do the below

var order = from x in orgContext.CreateQuery<"new_title">() select new { orderdate= x.GetAttributeValue<DateTime>("new_orderdate") }; order = from x in order where x.orderdate.Date == _today select x;

I am getting error at the second step.

My idea was to join orders and order to select the records. but no success.

Any idea is appreciated.


Viewing all articles
Browse latest Browse all 8223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>