Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7007743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:38:48+00:00 2026-05-27T21:38:48+00:00

I need to check if two dates are equal in Linq query and the

  • 0

I need to check if two dates are equal in Linq query and the dates come from two different tables (not as a parameter). I have looked at existing solutions on the web and also in SO. some are not applicable in my case and some are not elegant. just looking for better alternate solution if there is any.

sample query (need to compare only date portions):

var query = from t1 in Table1
            join t2 in Table2 on t1.Id equals t2.ForeignKeyId
            where t1.Id = someId
               && t1.Date1.Date.Equals(t2.Date2.Date)

this one fails with an error “‘Date’ is not supported in LINQ to Entitiies. Only initializers, entity members, and entity navigation properties are supported”

the post 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported has a solution which compares day,month and year separately. I tried to wrap it into an extension method, but it seems Linq doesn’t like extension methods either. since the second date is not a variable, I can’t use the other solution mentioned in the linked post (and I can’t call “AddDays” method on a date inside Linq for some reason). It looks like there are many limitations with Date API in Linq.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:38:48+00:00Added an answer on May 27, 2026 at 9:38 pm

    Try to use DiffDays from EntityFunctions class.
    Personally never used this, but worth to try like this:

    var query = from t1 in Table1
            join t2 in Table2 on t1.Id equals t2.ForeignKeyId
            where t1.Id = someId
               && EntityFunctions.DiffDays(t1.Date1, t2.Date2) == 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

$('tr').find(need help here).parent().css('backgroundColor', '#fcc'); Would like to perform inequality check of two dates (both
Need to check wether a given date is in between two given dates using
I need to check if a database is totally empty (no tables) using an
I need to check specific positions in an NSArray to see if they have
I need to check if a TCP/IP route already exists from my application and
I need to compare two dates to show an edit link if it is
I need to check if a date(in string) exists in array list. I have
I want to compare between two dates. From both the dates, I am fetching
I have to write a JavaScript function that checks if two dates (formatted dd/MM/yyyy
I need to find out if two dates the user selects are the same

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.