web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Comparing only date part of datetime field with another date

(0) ShareShare
ReportReport
Posted on by 145

Hi , 

I have a datetime field that i want to compare only the date part of it with another date in a LINQ query , but an error is thrown , here is a code snippet :


var currentDate = DateTime.UtcNow.Date;
var contacts = (from c in service.ContactSet
&& c.new_testDate.Value.Date.Equals(currentDate)
select c
).ToList();

the error :

"Invalid 'where' condition. An entity member is invoking an invalid property or method."

is it a LINQ limitation ? and how can we solve it ? Thanks.

I have the same question (0)
  • Khaled Rimawi Profile Picture
    145 on at

    Edit :

    Here is the write code snippet :

    var currentDate = DateTime.UtcNow.Date;

    var contacts = (from c in service.ContactSet

    where c.new_testDate.Value.Date.Equals(currentDate)

    select c

    ).ToList();

  • erhan.keskin Profile Picture
    2,253 on at

    can you try this please?

    where c.new_testDate.Value.Date == currentDate

  • Khaled Rimawi Profile Picture
    145 on at

    @Erhan Keskin , same error

  • erhan.keskin Profile Picture
    2,253 on at

    There are solutions here, please have a look and choose the best one for you.

    www.codeproject.com/.../LINQ-query-to-compare-only-date-part-of-DateTime

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 76

#3
Martin Dráb Profile Picture

Martin Dráb 64 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans