ADD_PERIOD

Use the ADD_PERIOD script function to add a period to a date. The function lets you specify the period as years, months, quarters, or weeks. You can add any number of periods to the date.

Syntax

ADD_PERIOD ([Date Format:]Date, Period Format:Period[, Output Format] )

Parameters

Return Code

The script function returns the resulting date in either the default YYMMDD format, or in the date format that you specify. Keep the output format in mind when you subtract years, quarters and months.

Important! The script results in an error if the calculated date lies after the date 12/31/9999.


Examples

The following example adds two weeks to a date, and prints the result (20.03.2018) in the activation report.

:SET &DATE#=ADD_PERIOD ("DD.MM.YY:06.03.18","WW;2","DD.MM.YYYY")
:
PRINT &DATE#

The following example adds a quarter to a date, and prints the result (30-04-2018) in the activation report.

:SET &DATE#=ADD_PERIOD ("180131","Q:1","DD-MM-YYYY")
:
PRINT &DATE#

The following example adds a year to a date, and prints the result in the activation report. The script selects the last day of February in the target year, so the result is 28.2.2001 because 2001 is not a leap year.

:SET &DATE#=ADD_PERIOD ("20000229","YY:0001",DD.MM.YYYY)
:
PRINT &DATE#

See also:

seealso

Script Date and Time Functions

Date, Time and Period Formats in Scripts