SUB_PERIOD
Use the SUB_PERIOD script function to subtract a period from a date. You can specify the period in years, months, quarters, or weeks, and subtract any number of periods.
Important! The function returns an error if the calculated date falls before the year 0000.
Syntax
SUB_PERIOD ([Date Format:]Date, Period Format:Period[, Output Format])
Parameters
| Parameter | Description | Format | Default Value |
|---|---|---|---|
| Date | Date in YYMMDD or YYYYMMDD format, unless a different format is specified. To use a different format, enter it followed by a separator (: or ;) before the date. | script literal or script variable | n.a. |
| Period Format:Period | Period format (years, quarters, months, or weeks) and number of periods to subtract, separated by : or ;. For more information, see Date, Time and Period Formats in Scripts. | n.a. | n.a. |
| Output Format
(Optional) |
Format of the resulting date. Keep the output format in mind when subtracting years, quarters, and months. | AE name, script literal or script variable | YYMMDD |
Return Codes
The SUB_PERIOD function returns the resulting date in YYMMDD format by default, or in the format specified by the Output Format parameter.
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: