Skip to content
Loading
In date range Start date should be one month before the current date  
  •   
  •   
  • And here's my controller code
    1. [HttpPost]  
    2. [ValidateAntiForgeryToken]  
    3. public ActionResult All(int? Employee, int? page, string start, string end)  
    4. {  
    5. List attendanceList;  
    6. if (Employee != null)  
    7. {  
    8. if (start != "" && end != "")  
    9. {  
    10. DateTime dtstart = Convert.ToDateTime(start);  
    11. DateTime dtend = Convert.ToDateTime(end);  
    12. attendanceList = db.Attendance.ToList().Where(x => x.Emp_Id == Employee && x.Date >= dtstart && dtend >= x.Date).ToList();  
    13. }  
    14. else  
    15. {  
    16. attendanceList = db.Attendance.ToList().Where(x => x.Emp_Id == Employee).ToList();  
    17. }  
    18. return View(attendanceList);  
    19. }  

    3 Replies

    Know the answer? Post it — somebody with the same question will find it here.