Skip to content

PERIOD

SELECT
PERIOD_DIFF(200802, 200801) AS PeriodDifference;
+-------------------+
| PeriodDifference |
+-------------------+
| 1 |
+-------------------+

The PERIOD_DIFF function in MySQL returns the number of months between periods P1 and P2. In the example, it returned 1, as the difference between ‘200802’ and ‘200801’ is one month.