MONTH_BETWEEN

The MONTH_BETWEEN function returns the number of months between two dates.

Syntax

MONTH_BETWEEN( date1, date2 );

date1

The first date.

date2

The second date

Results

If date2 is later than date1, then the result is positive.

If date2 is earlier than date1, then the result is negative.

If date1 and date2 are either the same days of the month or both last days of months, then the result is always an integer.

Examples

splice> VALUES(MONTH_BETWEEN(CURRENT_DATE, DATE('2015-8-15')));
1
----------------------
3.0

splice> SELECT MIN(BirthDate) "Oldest",
   MAX(Birthdate) "Youngest",
   MONTH_BETWEEN(MIN(Birthdate), MAX(BirthDate)) "Months Between"
   FROM Players;
Oldest     |Youngest   |Months Between
--------------------------------------------
1975-07-14 |1992-10-19 |207.0

1 row selected

See Also