MySQL PERIOD_DIFF Function

MySQL PERIOD_DIFF is one of the Date Functions, which returns the total number of months between Periods 1 and 2. It accepts the arguments in YYYYMM, or YYMM formats only, and the basic syntax of it is as shown below:

PERIOD_DIFF(Period1, Period2);

PERIOD_DIFF Example

This MySQL Period difference accepts either the YYMM or YYYYMM format value as an argument value.

The following Date method examples help you understand the use of this MySQL function. In this example, we are finding the total number of months between different dates.

SELECT PERIOD_DIFF(201608, 201602);

SELECT PERIOD_DIFF(201608, 201209);

SELECT PERIOD_DIFF(7508, 7609);
PERIOD_DIFF Example