I have a SQL query like this:
SELECT date FROM cases
WHERE date BETWEEN '11/01/2015' AND '11/15/2015'
I want to do the same thing in MVC Controller using Linq. So what I have is this:
DateTime today = DateTime.Today;
var case = _dataContext.tb_cases;
var result=(from c in case
select new
{
date=c.date
...
}).Where(p=>p.date >= new DateTime(2015,11,01)&& p.date < today).ToList();
return Json(result, JsonRequestBehavior.AllowGet);
But somehow I couldn't get any result when comparing the date
between new DateTime(2015,11,01)
and today
, and I do have data returned when I use SQL query in my database. I'd also like to set up my date format as same as those two in SQL query.
Anyone can help me to solve this problem?
Thank you very much!
Kevin