title: Oracle - literal does not match format string
body: <p>I have a function which takes 2 date parameters:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION date_equal
  (
      date1 IN DATE,
      date2 IN DATE
  )
  RETURN NUMBER IS
      equal BOOLEAN;
  BEGIN
      equal := NVL(date1, '1999-01-01') = NVL(date2, '1999-01-01');
      IF equal THEN
          RETURN 1;
      ELSE
          RETURN 0;
      END IF;
  END date_equal;
  /
  </code></pre>
  
  <p>Now, when I run select on the table which provides data for the function it runs okay:</p>
  
  <pre><code>SELECT TO_DATE(some_date, 'YYYY-MM-DD') FROM tbl
  </code></pre>
  
  <p>But when I try to use that in function call it fails:</p>
  
  <pre><code>SELECT date_equal(TO_DATE(some_date, 'YYYY-MM-DD'), TO_DATE(some_date, 'YYYY-MM-DD')) FROM tbl
  </code></pre>
  
  <p>The error message is "literal does not match format string". Does anyone know why would that happen?</p>