DATETIME.TODAY IN MVC

jacob rasel

Total Post:88

Points:616
Posted by  jacob rasel
 1006  View(s)
Ratings:
Rate this:

I am trying to return a view which will display the logs from current day.

This sql query does exactly what i need.

select * from Logs where Date>=GETDATE()-1

but I am having trouble with the razor syntax to write this statement in my view.

return View(db.Logs.Where(a => a.Date >= DateTime.Today() - 1));

Any idea how to display logs in the view for the current date?

  1. Kamlakar Singh

    Post:194

    Points:1396
    Re: DateTime.Today in mvc

    try this:

    return View(db.Logs.Where(a => a.Date == DateTime.Today));

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!