MySQL PERIOD_ADD() Function
THE WORLD'S LARGEST WEB DEVELOPER SITE

MySQL PERIOD_ADD() Function

❮ MySQL Functions

Example

Add a specified number of months to a period:

SELECT PERIOD_ADD(201703, 5);
Try it Yourself »

Definition and Usage

The PERIOD_ADD() function takes a period and adds a specified number of months to it.

The PERIOD_ADD() function will return the result formatted as YYYYMM.

Syntax

PERIOD_ADD(period, number)

Parameter Values

Parameter Description
period Required. A period formatted as YYMM or YYYYMM
number Required. The number of months to add to the period. Can be a positive or negative value

Technical Details

Works in: MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23

More Examples

Example

Add a specified number of months to a period:

SELECT PERIOD_ADD(201703, 15);
Try it Yourself »

Example

Add a specified number of months to a period:

SELECT PERIOD_ADD(201703, -2);
Try it Yourself »

❮ MySQL Functions