title: C# SQL statement Date Range
body: <p>I would like to use SQL statement to "filter" or display the data that lies within date range.</p>
  
  <p>Here is an example:</p>
  
  <pre><code>SELECT PRODUCTNAME, PRODUCTID, DESCRIPTION, EXPIREDDATE 
  FROM PRODUCT TABLE 
  WHERE EXPIREDDATE &lt; (SELECT GETDATE())
  </code></pre>
  
  <p>The above query is able to get <code>ExpiredDate</code> of an product for example.</p>
  
  <p>Now I am trying to let user know the following month (which will be inputted by themselves) list of product that are going to expired.</p>
  
  <p>Let me elaborate: if user enters '3', then starting from today let's say <em>2020-01-01</em>, until the next 3 months which will be <em>2020-04-01</em>, while the <code>ExpiredDate</code> falls within that daterange, the list of product will be shown back to the user</p>
  
  <pre><code>public object expiredProduct (int month) //month will be user inputted value 
  {
      // I skipped database connection here
      SqlCommand command = new SqlCommand();
  
      // what should I write here for comparing the date?
      command.CommandText = SELECT PRODUCTNAME, PRODUCTID, DESCRIPTION, EXPIREDDATE FROM PRODUCT TABLE WHERE EXPIREDDATE &lt; (SELECT GETDATE())  
  
      return list; // I return back my data here
  }
  </code></pre>
  
  <p>How should I write for the above query?</p>
  
  <p><strong>Requirement</strong></p>
  
  <p>My date is <code>DateTime</code> datatype. I am using C# Web API.</p>