title: Filter by DateTime Range MVC 5
body: <p>Good evening everyone,
  I home, anyone can help my with Date time range filter on  view part.
  Here is my model:</p>
  
  <pre><code>public class IndexVM
  {
      public DateTime? StartDate { get; set; }
      public DateTime? EndDate { get; set; }
      public virtual ICollection&lt;Order&gt; Orders { get; set; }
  
  }
  </code></pre>
  
  <p>I'm using view models for display, now here is my controller:</p>
  
  <pre><code>public ActionResult Index(DateTime? start, DateTime? end)
      {
  
          var orders = db.Orders
              .Where(x =&gt; x.OrderStatus == 3
              &amp;&amp; x.ClosedAt &gt; start
              &amp;&amp; x.ClosedAt &lt; end)
              .OrderByDescending(x =&gt; x.LastUpdateAt)
              .ToList();
  
          IndexVM model = new IndexVM();
          model.StartDate = start;
          model.EndDate = end;
          model.Orders = orders;
          return View(model);
      }
  </code></pre>
  
  <p>Now I have some problems with view.</p>
  
  <p><strong>Here is My QUESTION:</strong>
  How to  pass start and end date to controller to get orders with defined properties?
  Here is My View and what I'm doing wrong?</p>
  
  <pre><code>@using (Html.BeginForm())
  {
      &lt;div class="form-horizontal"&gt;
          &lt;div class="form-group form-group-sm"&gt;
              &lt;div class="col-md-8"&gt;
                  @Html.TextBoxFor(model =&gt; model.StartDate, "{0:MM/dd/yyyy}", new { @class = "date-picker form-control", @id = "start", @placeholder = "Start Date" })
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="form-group form-group-sm"&gt;
              &lt;div class="col-md-8"&gt;
                  @Html.TextBoxFor(model =&gt; model.EndDate, "{0:MM/dd/yyyy}", new { @class = "date-picker form-control", @id = "end", @placeholder = "End Date" })
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="form-group-sm"&gt;
              &lt;div class="col-md-offset-2 col-md-10"&gt;
                  &lt;input type="submit" value="Save" class="btn btn-default" /&gt; &lt;span&gt; &lt;/span&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  }
  </code></pre>