I am trying out a linq query check expiry by comparing a saved date and current date in mvc3 controller
[AllowAnonymous]
public ActionResult _leftHomeAd()
{ var LhAd = db.Adverts
.Where(u => u.ACatId ==1)
.Where(u => u.OffDate <= DateTime.Now.Day);
return PartialView(LhAd);
And I get the error that I cannot use <= for system date. Can someone point me in the right direction so that my query can retrieve only adverts that have not expired.
Why are you using
DateTime.Now.Day? Change it: