totn MariaDB Functions

MariaDB: PERIOD_ADD Function

This MariaDB tutorial explains how to use the MariaDB PERIOD_ADD function with syntax and examples.

Description

The MariaDB PERIOD_ADD function takes a period (formatted as YYMM or YYYYMM) and adds a specified number of months to it.

Syntax

The syntax for the PERIOD_ADD function in MariaDB is:

PERIOD_ADD( period, number )

Parameters or Arguments

period
A period formatted as either YYMM or YYYYMM.
number
The number of months to add to the period. It can be a positive or negative value.

Note

  • The PERIOD_ADD function will return the result formatted as YYYYMM.

Applies To

The PERIOD_ADD function can be used in the following versions of MariaDB:

  • MariaDB 10

Example

Let's look at some MariaDB PERIOD_ADD function examples and explore how to use the PERIOD_ADD function in MariaDB.

For example:

SELECT PERIOD_ADD(201406, 2);
Result: 201408

SELECT PERIOD_ADD(201406, 6);
Result: 201412

SELECT PERIOD_ADD(201406, 7);
Result: 201501

SELECT PERIOD_ADD(201406, 12);
Result: 201506

SELECT PERIOD_ADD(201406, -1);
Result: 201405

SELECT PERIOD_ADD(1406, 5);
Result: 201411

SELECT PERIOD_ADD(1406, 6);
Result: 201412