title: c# - Drop Down List of Date Ranges to Filter Relevant Data
body: <p>I have to create a drop down that will allow the user to select a date range, and given their selection, display all records with dates between the range. </p>
  
  <p>I know how to query one range (code snippet below), but how do I query such that the drop down only populates with the options of "Last 7 Days", "Last 15 Days", "Last 30 Days", "Last 60 Days", and "All Transactions" (and then displays the corresponding transactions based on selection)?</p>
  
  <p>Also would be nice to know how to have an option called "Custom" that allows the user to input their own date range, but that is not a priority.</p>
  
  <p>What I have below will query and display transactions within the last seven days, but this obviously is not achieving what I am looking for.</p>
  
  <pre><code>public SelectList GetDateRanges()
      {
          DateTime today = DateTime.Today;
          DateTime minusSeven = today.AddDays(-7);
          DateTime minusFifteen = today.AddDays(-15);
          DateTime minusThirty = today.AddDays(-30);
          DateTime minusSixty = today.AddDays(-60);
  
          var query = from t in db.Transactions
                      where t.TransactionDate &gt;= minusSeven
                      select t;
  </code></pre>
  
  <p>My thought is that I possibly could create a static list, but then I don't know how I would query based on a user's selection within that list.</p>