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
- 
                                                SUB_PERIOD 
 Subtracts periods from a date
- 
                                                Date 
 Date in YYMMDD or YYYMMDD format, unless you specify a different format
 (Optional) To specify a different date format, enter the desired date format and a separator (: or ;) before the date.
 Format: script literal or script variable
- 
                                                Period Format:Period 
 Specifies the period format (years, quarters, months or weeks), and the number of periods to subtract from the date
 Note: Use : or ; as a separator between the period format and the number of periods.
 More Information: Date, Time and Period Formats in Scripts
- 
                                                Output Format 
 (Optional) Format of the resulting date
 Format: AE name, script literal or script variable
 Default format: YYMMDD
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: