MySQL PERIOD_DIFF Function

MySQL PERIOD_DIFF function is one of the MySQL Date Functions, which returns the total number of months between Period 1 and 2. This PERIOD_DIFF function accepts the arguments in YYYYMM or YYMM formats only. The basic syntax of the PERIOD_DIFF() Function in MySQL is as shown below:

PERIOD_DIFF(Period1, Period2);

MySQL PERIOD_DIFF function Example

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

The following Date Function examples help you understand the use of this MySQL Period diff function. In this MySQL 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);
MySQL PERIOD_DIFF Function 1