title: Filter Date from dropdownlist in ASP.NET MVC 5 project
body: <p>This is the code in the controller:</p>
  
  <pre><code>// select only present date and distinct date for dropdownlist
  var eventDate = from e in db.EVENTS
                  .GroupBy(e =&gt;new { e.EventDate})
                  .Select(e =&gt; new { e.Key.EventDate})
                  .OrderBy(e =&gt; e.EventDate)
                  .Where(e =&gt; e.EventDate &gt;= DateTime.Now)
                  select e;
  
  var ddlDate = from d in eventDate
                select d.EventDate;
  
  ViewBag.EventDate = ddlDate;
  </code></pre>
  
  <p>This is markup in index.cshtml:</p>
  
  <pre><code>&lt;div class="col-12 col-md-2  col-lg-1 pb-1"&gt;
      &lt;label class="col-form-label font-italic text-center"&gt;Filter :&lt;/label&gt;
  &lt;/div&gt;
  &lt;div class="col-6 col-sm-5 col-md-4 col-lg-2 pb-1"&gt;
      @Html.DropDownList("searchCampus", new SelectList(ViewBag.Campus), "Select campus", new { @class = "form-control" }) &lt;br /&gt;
  &lt;/div&gt;
  &lt;div class="col-6 col-sm-5 col-md-4 col-lg-2 pb-1"&gt;
  @Html.DropDownList("searchDate", new SelectList(ViewBag.EventDate), "Select Event date", new { @class = "form-control" })
   &lt;/div&gt;
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/l0AhF.png" alt="Date filter querystring mvc5"></p>
  
  <p>I have an <code>EventDate</code> dropdownlist as a filter for my data. But I cannot compare my date in the query string to my <code>DateTime</code> datatype for <code>EventDate</code> column. I can see the date in the query string in my URL has <code>%</code> sign and other things mixing with my date. </p>
  
  <p>How do I filter by date (dropdownlist is a list of <code>eventdate</code> I pull from <code>EventDate</code> column in database table), so when the user selects one of <code>EventDate</code> from dropdownlist, I want to show only the data that matches the <code>EventDate</code>.</p>
  
  <p>Can you help me please?</p>