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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:35:01+00:00 2026-05-31T00:35:01+00:00

I have var q = db.Games.Where(t => t.StartDate >= DateTime.Now).OrderBy(d => d.StartDate); But it

  • 0

I have

var q = db.Games.Where(t => t.StartDate >= DateTime.Now).OrderBy(d => d.StartDate);

But it compares including time part of DateTime. I really don’t need it.

How to do it without time?

Thank you!

  • 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-31T00:35:02+00:00Added an answer on May 31, 2026 at 12:35 am

    Just use DateTime.Today property to take the current date. There’s no need to truncate t.StartDate in this case (and doing so may incur performance penalties).

    var today = DateTime.Today;
    
    var q = db.Games.Where(t => t.StartDate >= today)
                    .OrderBy(t => t.StartDate);
    

    Note that I’ve explicitly evaluated DateTime.Today once so that the query is consistent – otherwise each time the query is executed, and even within the execution, Today could change, so you’d get inconsistent results. For example, suppose you had data of:

    Entry 1: March 8th, 8am
    Entry 2: March 10th, 10pm
    Entry 3: March 8th, 5am
    Entry 4: March 9th, 8pm
    

    Surely either both entries 1 and 3 should be in the results, or neither of them should… but if you evaluate DateTime.Today and it changes to March 9th after it’s performed the first two checks, you could end up with entries 1, 2, 4.

    Of course, using DateTime.Today assumes you’re interested in the date in the local time zone. That may not be appropriate, and you should make absolutely sure you know what you mean. You may want to use DateTime.UtcNow.Date instead, for example. Unfortunately, DateTime is a slippery beast…

    EDIT: You may also want to get rid of the calls to DateTime static properties altogether – they make the code hard to unit test. In Noda Time we have an interface specifically for this purpose (IClock) which we’d expect to be injected appropriately. There’s a "system time" implementation for production and a "stub" implementation for testing, or you can implement it yourself.

    You can use the same idea without using Noda Time, of course. To unit test this particular piece of code you may want to pass the date in, but you’ll be getting it from somewhere – and injecting a clock means you can test all the code.

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

Sidebar

Related Questions

I have this: var date = new DateTime(2009, 12, 5); ... ... and need
I have var row=<tr><td>val</td><td>val2</td></tr> and I tried this: $(#mainTable tbody).append(row); but it appends to
I have a var that contains a full html page, including the head, html,
I have the following query: var data = from d in dc.GAMEs where (d.GAMEDATE
I have an object for like this: var obj = { c: { games:
I have this simple query -> var games = from p in _oListGames where
Imagine I have var points = new Point[] { new Point(1, 2), new Point(2,
Here's the code I have: var commandsBuffer = List[String]() commandsBuffer ::= cmd.exe commandsBuffer ::=
I have DocumentRoot /var/www/test in my .htaccess file. This is causing the apache server
I have this var n = ItemList.Select(s => new { s.Vchr, s.Id, s.Ctr, s.Vendor,

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.