title: SQL Query NOT Between Two Dates
body: <p>I need some help with SQL Query. </p>
  
  <p>I am trying to select all records from table <code>test_table</code> which would not fit between two dates '2009-12-15' and '2010-01-02'.</p>
  
  <p>This is my table structure:</p>
  
  <pre><code>`start_date` date NOT NULL default '0000-00-00',
  `end_date` date NOT NULL default '0000-00-00'
  
  -----------------------------
   **The following record should not be selected:**
  
  `start_date`, `end_date`
  '2003-06-04', '2010-01-01'
  </code></pre>
  
  <p>My query:</p>
  
  <pre><code>SELECT * 
  
  FROM `test_table` 
  WHERE 
  
  CAST('2009-12-15' AS DATE) NOT BETWEEN start_date and end_date 
  AND 
  CAST('2010-01-02' AS DATE) NOT BETWEEN start_date and end_date
  </code></pre>
  
  <p>Any idea why my query select wrong records? Should I change the order of values in query to something like: </p>
  
  <pre><code>start_date NOT BETWEEN CAST('2009-12-15' AS DATE) and CAST('2010-01-02' AS DATE)
  </code></pre>
  
  <p>Thanks a lot for any help</p>