Definition: The Oracle MONTHS_BETWEEN calculates the month difference between two given dates. It accepts two date inputs and returns an integer value. It also considers the difference of time components of the two dates. When both dates have the same day component or are the last day of the month, the returned value is a whole number. If not, the returned value includes a fraction that approximates the difference in the days based on a 31-day month.

Example Syntax:

MONTHS_BETWEEN (D1, D2)

where D1 and D2 are of date datatype.

Example Usage:

As shown in the SQL statement below, if the first argument date is greater than second argument date, the result is positive.