SUB_PERIOD

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

Syntax

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

Parameters

Return Code

The script functions 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 before the year 0000.

Examples

The following example subtracts two weeks from a date, and prints the result (21.06.2018) in the activation report.

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

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

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

The following example subtracts a year from a date, and prints the result (28.02.2018) in the activation report.

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

See also:

seealso

Script Date and Time Functions

Date, Time and Period Formats in Scripts