title: SQL Query Date between, if date column not null
body: <p>I have a query as follows</p>
  
  <pre><code>SELECT ajd.Make, ajd.Model, ajd.Filter, ajd.Notes, ajd.CatamacPartNumber, ajd.FromDate, ajd.ToDate 
    FROM ApplicationJapData ajd 
    WHERE ajd.Model LIKE '%FVR34%' 
    AND FromDate &lt;= '20140701' AND ToDate &gt;= '20140701'
  </code></pre>
  
  <p>What this query does is select rows based on <code>Model</code> containing certain search string, and where supplied date is between columns <code>FromDate</code> and <code>ToDate</code>.</p>
  
  <p>The problem is that sometimes ToDate is <code>null</code>, because it is up to current date (For instance, <code>FromDate</code> = <code>1/1/2015</code>, and <code>ToDate</code> is <code>null</code> because it is <code>1/1/12</code> - <code>Present</code>)</p>
  
  <p>So if I supply a value of 12-12-2015, I would still like to return rows if it meets the <code>FromDate</code> condition.</p>
  
  <p>However, I can't use <code>OR</code> in  <code>FromDate &lt;= '20140701' OR ToDate &gt;= '20140701'</code>
  because there might be <code>ToDate</code> of <code>1-6-15</code>, in which case it would be incorrect with supplied date of <code>12-12-2015</code></p>
  
  <p>Any help is much appreciated, and please ask if anything is unclear or needs clarifying!</p>