title: Display Results by Date ASP.NET MVC
body: <p>Can anybody please tell me where I am going wrong with this. I have a list of errors and I want to be able to search by date. For example, if I selected the date, 20/08/2015, from a date picker, then I want the list to just show errors from that date. By default it will show all the errors in the database, but when a date is selected, I want to show only the errors from that date.</p>
  
  <h3>Controller</h3>
  
  <pre><code>[HttpPost]
  public ActionResult Index(string sortOrder, int? page, DateTime? datePicker)
  {
      ViewBag.CurrentSort = sortOrder;
      ViewBag.DateSortParm = sortOrder == "Date" ? "date_desc" : "Date";
  
      DateTime userSelectedDate = DateTime.Parse(Request["datePicker"]);
  
      var applications = from s in db.ElmahErrors
                         where s.TimeUtc == userSelectedDate
                         select s;
  
      switch (sortOrder)
      {
          default:
              applications = applications.OrderByDescending(x =&gt; x.TimeUtc);
              break;
      }
  
      int pageSize = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["DefaultPageSize"]);
      int pageNumber = (page ?? 1);
      return View(applications.ToPagedList(pageNumber, pageSize));
  }
  </code></pre>
  
  <h3>View</h3>
  
  <pre><code> @using (Html.BeginForm())
  {
      &lt;label for="datePicker"&gt;Find By Date:&lt;/label&gt;
  
      @Html.TextBox("datePicker", null, new { @type = "date" })
  
      &lt;input id="submitBtn" type="submit" value="Search" /&gt;
  }
  </code></pre>
  
  <p>The <code>userSelectedDate</code> variable is taking in the value from the date picker, but it doesn't match any of the errors. Can somebody please help?</p>
  
  <p>Thanks in advance.</p>