Script Function: Subtracts a period from a specified date.
SUB_PERIOD(Date, Period Format:Period, [Output Format])
Syntax |
Description/Format |
---|---|
Date |
Indication of a date in the format "YYMMDD" or "YYYYMMDD". Format: script literal or script variable It is also possible to specify a different date format. Do so by entering the required date format, then enter a separator (: or ;) and afterwards the date. Indicating a date format is optional. |
Period Format:Period |
Format: script literal or script variable. Period: Specification of a period to be subtracted from the specified date. Use a colon (:) or semi colon (;) as a separator between the Period Format and the Period. |
Output Format |
Format guidelines for the determined date. |
Return code |
---|
Date in the specified format |
This script function subtracts years, months, quarters or weeks from a specified date.
A date is assigned to this script function. Optionally, you may specify a particular Date Format. The default Date Formats to be used are "YYMMDD" or "YYYYMMDD". A colon or semicolon may be used as a separator between Date Format and Date.
The Period is subtracted from the specified Date. The Period may be any number. An error will occur if the result is a date which dates before the year 0000.
Output Format is an optional parameter. This script function returns a date in the default format "YYMMDD" if Output Format has not been specified.
Keep this in mind when subtracting years, quarters and months.
The first example subtracts two weeks from 07/5/2000. The result (21.06.2000) is output in the report.
:SET &DATE#=SUB_PERIOD ("DD.MM.YY:05.07.00","WW;2","DD.MM.YYYY")
:PRINT &DATE#
The second example subtracts a quarter from 07/31/2000. The result (30-04-2000) is output in the report.
:SET &DATE#=SUB_PERIOD ("000731","Q:1","DD-MM-YYYY")
:PRINT &DATE#
In the third example, a year is subtracted from 02/28/2001. 28.02.2000 is output in the report.
:SET &DATE#=SUB_PERIOD ("20010228","YY:0001",DD.MM.YYYY)
:PRINT &DATE#
See also:
Script Elements - Date and Time
About Scripts
Script Elements - Alphabetical Listing
Script Elements - Listed by Function