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 8521493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:50:35+00:00 2026-06-11T06:50:35+00:00

i heard people saying date time comparison do not work just due to time

  • 0

i heard people saying date time comparison do not work just due to time part because datetime has time part.

in sql i always compare datetime like this way and it works fine

select * from employee
where convert(varchar,dob,112) > '20111201' // this yyyymmdd format.

how could i simulate this in a LINQ query?

  • 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-06-11T06:50:37+00:00Added an answer on June 11, 2026 at 6:50 am

    The one thing to keep in mind is that operations on DateTime structs that represent database columns don’t translate to SQL. So, you cannot write a query like:

    from e in EfEmployeeContext
    where e.DOB.Date > new DateTime(2011,12,01);
    

    … because e.DOB represents the DOB column in the database, and EF won’t know how to translate the Date sub-property.

    However, there’s an easy workaround depending on what dates you want:

    • If you want to include all employees that have a DOB on 12/01/2011 as well as those born after that date, then simply query:

      from e in EfEmployeeContext
      where e.DOB > new DateTime(2011,12,01);
      
    • If you want to include only employees born after 12/01/2011, then query:

      from e in EfEmployeeContext
      where e.DOB >= new DateTime(2011,12,02);
      

    In short, the criteria, meaning a constant or literal DateTime you’re comparing against, can be set up however you want. You just can’t make radical modifications to properties that represent DB columns within the where predicate. That means you can’t compare one DateTime column to a projection of another DateTime column, for instance:

        //get all employees that were hired in the first six months of the year
        from e in EfEmployeeContext
        where e.HireDate < new DateTime(e.HireDate.Year, 7, 1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have heard some people saying if main is not static then JVM could
Sometimes I heard people discussing about the start-up time for Java. It seems this
Time and time again I've read and heard people frustrated over Maven and how
I have heard people saying a JVM is necessarily a Java interpreter but a
I am writing tests and I have heard some people saying to use self.assertFalse
I heard a lot of people saying that java is slow comparing .net, like
I have heard a lot of people saying that to be a good programmer
I'm just learning the basics of socket programming for C++, but I've heard people
I often heard people saying that stored procedures are pre-compiled. What does it mean?
I have always heard people saying bad about using cursors and this is especially

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.