date range datepicker c #

0

I have a problem, I need to filter two dates from a table in the database and I could not, to see if they can guide me, it's in c #, my controller

public ActionResult Report(DateTime? start, DateTime? end)
    {
        using (var db = new bd_sistema_SPEC_adminEntities1())
        { 
            int t = db.mae_plantilla_maquina.Where(i => i.mpm_fecha_creacion>= start && i.mpm_fecha_modificacion <= end).Count();
        int r = db.mae_plantilla_maquina.Count(i => i.mpm_fecha_creacion != null && i.mpm_fecha_creacion >= start && i.mpm_fecha_modificacion <= end);
        ViewBag.EndDate = end;
        ViewBag.StartDate = start;
        ViewBag.Total = t;
        ViewBag.Read = r;
        return View();
    }
}

It turns out that in the view, I could not define so that I could try the code, I'm sorry, to see if they could help me, thank you very much:

I would like if you could have a view like this:

mvc search filter records between two data stored procedure c # 4.6

greetings

    
asked by KonnAN 20.12.2018 в 20:18
source

1 answer

1

You should try to put the BETWEEN statement instead of => which is actually >= .

I'll leave your modified line of code, hoping it will help you.

int t = db.mae_plantilla_maquina.Where(i >= i.mpm_fecha_creacion between start && i.mpm_fecha_modificacion between end).Count();
    
answered by 20.12.2018 в 21:04