MONTHS_BETWEEN function returning wrong negative values
924842Mar 21 2012 — edited Apr 4 2012Hello all,
The following is the query I am puzzling over:
select to_char(sysdate,'dd-MON-yyyy') AS TODAY, TO_CHAR(HYPOTHETICAL_DATE, 'dd-MON-yyyy') AS HYPOTHETICAL_DATE,
months_between(sysdate,HYPOTHETICAL_DATE) AS DIFF_IN_MONTHS from TableX
My result is:
TODAY HYPOTHETICAL_DATE DIFF_IN_MONTHS
21-MAR-2012 10-JUL-2020 -99,63109505675029868578255675029868578256
I am puzzled since in this case since the 2nd date is 8 years down the line my difference should be -8 and a fraction. So why am I getting -99?
Furthermore I would like to ignore the fractional part so the result I want for the above data is -8.
Please help.
Thanks
S. BASU