title: SQL Server select date year/month portion only without day and with comparison
body: <p>I have a list in a table with a <code>StartDate (not null)</code> and an <code>EndDate (null)</code> (both of type <code>date</code> without time).</p>
  
  <p>An active entry is one with <code>StartDate &lt;= querydate</code> and <code>EndDate with null or &gt; querydate</code>.</p>
  
  <p>So my query would basically be like</p>
  
  <pre><code>SELECT * 
  FROM MyDataTable 
  WHERE StartDate &lt;= mydate 
    AND (EndDate IS NULL OR EndDate &gt;= mydate )
  </code></pre>
  
  <p>For a statistic in a diagram, I want to know which ones are active in a specific month for the last months. I loop (programatically) over the year and month (2017-10, 2017-11, 2017-12, 2018-1, ... )</p>
  
  <p>How can I select all active entries using year and month of the program loop but ignoring the day part?</p>