c# - Comparing dates in linq -
I would like to query the DB for items equal to or equal to a date.
The date in DB is a time and time of record time.
If the user enters the search string "1/30/2014", then they expect the entries that come at any time of that date. However, nothing is returned once after 12 o'clock.
I know that I could only add one day to the search string, but is this a more appropriate way?
if (form ["closed" "] =" ") {datetime d = datetime purse (form [" off ""]); Mark = mark Where (s => gt; s.date_Closed & gt; =); }
You can use to reduce the portion of time: < / P>
traces = marks Where (s = & gt; s.date_Closed.Date & lt; = d.Date); In this way you add this day because both is the date of the date s is midnight. Update You can not use LINQ units like DateTime.Date , you can use this solution: . Where (S = & gt; unit function. TruncateTime (s.date_Closed) & lt; = EntityFunctions.TruncateTime (D))
Comments
Post a Comment