title: Difference between two dates
body: <p>I have a table that has the following data</p>
  
  <pre><code>fromDate | toDate
  20JAN11  | 29DEC30
  </code></pre>
  
  <p>Both dates are for the 21st Century (i.e. 2011 and 2030) but only the last two characters are stored. </p>
  
  <p>Why is the following statement (when run from within a PL/SQL module) against the above data always returns a positive value </p>
  
  <pre><code>dateDifference := (fromDate - toDate)
  </code></pre>
  
  <p>If i run the following statement from sqlplus i get the correct  negative value which is correct. </p>
  
  <pre><code>select to_date('20JAN11','DDMONYY')-to_Date('29DEC30','DDMONYY') from dual;
  </code></pre>
  
  <p>I remember reading somewhere that Oracle would sometimes use the wrong century but i dont quite remember the exact scenario where that would happen. </p>