SUB_DAYS

Use the SUB_DAYS script function to subtract a number of days from a given date. This function lets you optionally calculate the date depending on Calendar Events defined in a Calendar object.

Syntax

SUB_DAYS ([Date Format:]Date, Days[, Calendar, Calendar Event])

Parameters

Return Codes

This script function has the following return codes:

Note: The calendar calculation automatically considers the range of the specified calendar. The calendar range depends on the Client settings NOW_MINUS and NOW_PLUS. For more information, see UC_CLIENT_SETTINGS - Various Client Settings.

Examples

The following example subtracts two days from the specified date. The date is in the default YYMMDD format. The script prints the result (000330) in the activation report.

:SET &DATE# = SUB_DAYS("000401", 2)
:
PRINT &DATE#

The following example lets a user define how long to store something. The script assigns the current date to a script variable, and uses a :READ statement to query the user about the number of days. The SUB_DAYS function subtracts the number provided by the user from the current date.

:SET &CURRENTDATE# = SYS_DATE()  
:
READ &NUMBER#,"00","Enter how many days you want to store","08",N
:
SET &RETDATE# = SUB_DAYS(&CURRENTDATE#, &NUMBER#)

The following example retrieves the current date and subtracts two days. The current date is not in the default date format. The special date format is specified in the parameters of the SUB_DAYS function.

:SET &CURDATE# = SYS_DATE("DD.MM.YY")
:
SET &PWRKDAY# = SUB_DAYS("DD.MM.YY:&CURDATE#", 2)

See also:

seealso

Script Date and Time Functions

Date, Time and Period Formats in Scripts