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:
MySQL PERIOD_DIFF function Example
This MySQL Period difference function accepts either the YYMM or YYYYMM format value as an argument value.
The following examples help you understand the use of this MySQL Period diff function. Here, 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);