Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

PERIOD_ADD

Example

Increment a specified period by a given number of months.

SELECT PERIOD_ADD(2017035);

Definition and Usage

The PERIOD_ADD() function increments a specified period by a given number of months.

Note: The PERIOD_ADD() function returns the result formatted as YYYYMM after adding a specified number of months to a period.

Syntax

PERIOD_ADD(periodnumber)

Parameter Values

Parameter

Description

period

Mandatory: A period in the format YYMM or YYYYMM

number

Mandatory: Specifies the number of months to add to the period. Positive and negative values are both acceptable.

Technical Details

Works in:

 From MySQL version 4.0

More Examples

Example

Increase or decrease a period by a specified number of months.

SELECT PERIOD_ADD(20170315);

Example

Adjust a specified period by adding or subtracting a specified number of months.

SELECT PERIOD_ADD(201703, –2);