PERIOD_ADD
PERIOD_ADD is a MySQL date function that takes two arguments: a period (YYYYMM format) and a number of months to be added to this period. It returns the calculated period.
PERIOD_ADD(P, N)
- p: This is the period argument and it should be in the format YYMM or YYYYMM. It stands for the starting period to which we intend to add months.
- n: This is the integer argument representing the number of periods to add to P. The added periods will be in months. For instance, if the value of N is 3, three months will be added to the period P.
Example
Output
Explanation
The PERIOD_ADD
function in MySQL is used for adding a specified number of months to a period. In the given example, the function is adding ‘3’ months to ‘202102’, resulting in ‘202105’.