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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:50:17+00:00 2026-05-31T06:50:17+00:00

I have a Linq to Entity query that compares dates. I’m querying a SQL

  • 0

I have a Linq to Entity query that compares dates. I’m querying a SQL server 2008 database whose language is US English. My application handles dates in dd/MM/yyyy format.

itemList = from i in _context.Items
    select i;

DateTime utcStartDate = DateTime.SpecifyKind(StartDate, DateTimeKind.Utc);
DateTime utcEndDate = DateTime.SpecifyKind(EndDate, DateTimeKind.Utc);

var items= from i in itemList
       where c.ModifiedDate.Date >= utcStartDate.Date  &&
             c.ModifiedDate.Date <= utcEndDate.Date
       select i;

Here StartDate and EndDate are DateTime objects, which are read from textboxes (only dates are entered) and converted to DateTime. Typical values are: {8/3/2012 12:00:00 AM} for 08 March 2012.

This is how the value is specified when the column is updated in the database:

    item.ModifiedDate = DateTime.UtcNow.Date;

I cannot change the language settings at the Server. Is there any way to read the data from the SQL server and convert it to the “dd/MM/yyyy” format before comparing the dates?
Alternatively, what fornat should I convert the Datetime variables to so that the comparison works? What is the correct and efficient way to do this?

  • 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-31T06:50:19+00:00Added an answer on May 31, 2026 at 6:50 am

    The format only applies when treating the data as strings. The code shown doesn’t do that! It compares them as dates, transferring the parameters in their binary representation. Thus, there is no ambiguity, and no formatting involved at any point.

    Basically, this isn’t a problem. What you are asking is actually pretty similar to saying “how does SQL server order integers as “1,2,…,9,10,11” and not “1,10,11,2,…9” – to which the answer is “because it isn’t treating them as strings”.

    To be specific, datetime in sql server is actually treated as a decimal number, with the integer part being the day and the decimal part being the time; any “dd/MM/yyyy” or “yyyy/MM/dd” etc exists only for us poor fleshy readers. The server is not confused by such things.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following LINQ query that I need to translate to Entity SQL
I have a linq-to-sql query over entity that has child entityset that I need
I have a LINQ to ENTITY query that pulls from a table, but I
I have a LINQ query mapped with the Entity Framework that looks something like
I have a problem with the following Linq query using Entity Framework: from o
I have a simple LINQ query on ADO.NET Entity Framework as follows var result
I am using Linq and the Entity Framework. I have a Page Entity, that
I have a bunch of entity class (generated by Linq to SQL) with a
Say that I have LINQ query such as: var authors = from x in
I have a LINQ query that searches for multiple keywords on multiple columns. The

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.