Date_Of_Event.Date <= DateTime.Today.Date.AddDays(开发者_开发技巧-1))
You have the comparison backwards
// This should work in LINQ-to-SQL / EntityFramework
Date_Of_Event >= DateTime.Today.AddDays(-1)
&&
Date_Of_Event < DateTime.Today
or
// This will work in LINQ-to-Objects or anywhere else, really.
Date_Of_Event.Date == DateTime.Today.AddDays(-1)
As a side note, it may be a good idea to store the value of DateTime.Today
in a variable, so that weird bugs don't show up around midnight (or 11:00pm or 1:00am depending on daylight saving time).
Date_Of_Event.Date == DateTime.Today.AddDays(-1)
This will remove the time part of the date time, and keep only the date so you can check for equality instead of the time being inside the correct interval.
精彩评论