title: MONTHS_BETWEEN in Oracle.. Exact logic of calculation
body: <p>What is the exact logic behind Oracle's months_between function?<br>I tried this query:</p>
  
  <pre><code>SELECT D1, 
         D2, 
         MONTHS_BETWEEN (D1, D2) DIFF,
         (D1-D2)/31 MANUAL_CALC1,
         (D1-D2)/30 MANUAL_CALC2,
         (D1-D2)/29 MANUAL_CALC3,
         (D1-D2)/28 MANUAL_CALC4
  FROM (SELECT TO_DATE('07-03-2014', 'DD-MM-YYYY') D1, 
               TO_DATE('04-02-2014', 'DD-MM-YYYY') D2
          FROM DUAL);
  </code></pre>
  
  <p>And got result as:<br>
  DIFF: 1.09<br>
  MANUAL_CALC1: 1<br>
  MANUAL_CALC2: 1.03<br>
  MANUAL_CALC3: 1.06<br>
  MANUAL_CALC4: 1.10<br></p>
  
  <p>I am converting an Oracle package into a Java program and I need to generate exact same results. But just this one function (months_between) is spoiling the party.</p>