Home > DeveloperSection > Forums > DateTime.Today in mvc
jacob rasel
jacob rasel

Total Post:88

Points:616
Posted on    October-09-2014 12:31 AM

 ASP.NET MVC ASP.Net  ASP.NET MVC 
Ratings:


 1 Reply(s)
 699  View(s)
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?



Kamlakar Singh
Kamlakar Singh

Total Post:194

Points:1396
Posted on    October-09-2014 12:32 AM

try this:

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


Don't want to miss updates? Please click the below button!

Follow MindStick