title: Error in Oracle TO_CHAR() Function
body: <p>Why does the following error occur on Line 7 of the query below?</p>
  
  <p><code>Error: ORA-01861: literal does not match format string</code></p>
  
  <p><code>Query:</code></p>
  
  <pre><code>01: SELECT hour
  02: FROM (WITH all_hours AS
  03:             (SELECT TO_DATE ('2000-01-01', 'yyyy-mm-dd') 
  04:                      + NUMTODSINTERVAL (LEVEL - 1, 'hour') hour
  05:              FROM DUAL
  06:              CONNECT BY LEVEL &lt;= 1000000)
  07:      SELECT TO_CHAR (h.hour, 'yyyy-mm-dd hh:mi am') hour
  08:      FROM all_hours h
  09:      GROUP BY h.hour)
  10: WHERE hour BETWEEN TO_DATE ('2009-11-10 01:00 am', 'yyyy-mm-dd hh:mi am')
  11:                AND TO_DATE ('2009-11-10 01:00 am', 'yyyy-mm-dd hh:mi am')
  </code></pre>