title: SQL Server: WHERE Clause to exclude data in selection
body: <p>I have a table with persons, an <code>inactive-flag</code> (bit) indicating active/nonactive and <code>fromdate</code>, <code>todate</code>.</p>
  
  <ul>
  <li><p>a) Inactive=1 indicates that someone is general "not active".
  If there is a date in fromdate and todate field that means that in general he is not active <code>EXCEPT</code> during this date-period.</p></li>
  <li><p>b) Inactive=0 indicates that someone is general "active".
  If there is a date in <code>fromdate</code> and <code>todate</code> field that means that in general he is active <code>EXCEPT</code> during this date-period.</p></li>
  <li><p>c) Last Option are persons who have only Inactive=0, without any date exception (fromdate and todate field are <code>NULL</code>).</p></li>
  </ul>
  
  <p>I want to filter all persons a) and c), except b).</p>
  
  <p>I tried a lot, but could not solve the Problem.</p>
  
  <p>I found the solution for a) and c) but not for b).
  I tried for b):</p>
  
  <pre><code>WHERE inaktiv=0 AND (Not (fromdate &gt;=convert(date,getdate()) AND todate &lt;=convert(date,getdate())))
  </code></pre>