MySQL PERIOD_DIFF function is a Date Function, which is used to return the total number of months between Period 1 and 2. This function accepts the arguments in YYYYMM or YYMM formats only.
In this article, we will show you, How to use this MySQL Period difference function to find the difference between two periods with an example.
MySQL PERIOD_DIFF Syntax
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 helps 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);
Thank You for Visiting Our Blog