title: Oracle Recursive Query - Dates
body: <p>I've got two sets of dates being passed into a query and I would like to find all the months/years between both sets of dates.</p>
  
  <p>When I try this:</p>
  
  <pre><code>WITH CTE_Dates (cte_date)  AS (
      SELECT cast(date '2014-01-27' as date)  from dual
      UNION ALL
      SELECT cast(ADD_MONTHS(TRUNC(cte_date, 'MONTH'),1) as date)
      FROM CTE_Dates
      WHERE ( TO_DATE(ADD_MONTHS(TRUNC(cte_date, 'MONTH'), 1)) BETWEEN TO_DATE ('27-01-2014','DD-MM-YYYY') AND TO_DATE ('27-04-2014','DD-MM-YYYY'))
          OR
            ( TO_DATE(ADD_MONTHS(TRUNC(cte_date, 'MONTH'), 1)) BETWEEN TRUNC(TO_DATE('27-11-2014','DD-MM-YYYY'), 'MONTH')  AND TO_DATE ('27-01-2015','DD-MM-YYYY'))
        )
  SELECT * from CTE_Dates
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>27-JAN-14
  01-FEB-14
  01-MAR-14
  01-APR-14
  </code></pre>
  
  <p>I would also want to get:</p>
  
  <pre><code>01-NOV-14
  01-DEC-14
  01-JAN-15
  </code></pre>
  
  <p>It looks like the OR portion of the WHERE clause gets ignored.</p>
  
  <p>Suggestions on how to create this query?</p>
  
  <p>Thanks
  Cory</p>