ADD_DAYS
Use the ADD_DAYS script function to add days to a given date. This function lets you optionally calculate the date depending on Calendar Events that are defined in a Calendar object.
Syntax
ADD_DAYS ([Date Format:]Date, Days[, Calendar, Calendar Event])
Parameters
-
ADD_DAYS
Adds a number of days to a specified date -
Date Format
(Optional) Specify a format followed by a colon separator (;)
More Information: Date, Time and Period Formats in Scripts -
Date
Specifies the date
Format: script literal or script variable
Notes:- The date format applies to both the date you specify, and the date that the script function returns.
- If you do not specify a date format, use YYMMDD or YYYYMMDD
-
Days
Number of days to add to the date
Format: script literal, number without quotation marks or script variable
Tip: Specify 0 days to validate a date against a Calendar object. If the date is valid according to the Calendar, the script function returns the specified date. If the date is not valid, the script function returns the previous valid date based on calendar conditions. -
Calendar
(Optional) Name of a Calendar object
If you specify a Calendar object, the calculation only considers days that are defined in Calendar Events in the Calendar object.
Format: AE name, script literal or script variable
More Information: Calendars (CALE) -
Calendar Event
(Optional) Name of a Calendar Event, if you specify a Calendar object
Format: AE name, script literal or script variable
Return Codes
This script function has the following return codes:
- 0
No days are assigned to the Calendar Event, or the calculated date lies outside of the calendar range - 20327
Calendar object does not exist - 20328
Calendar Event does not exist in the Calendar object
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 adds two days to the specified date. The date is in the default YYMMDD format. The script prints the result (000401) in the activation report.
:SET &DATE# = ADD_DAYS("000330", 2)
:PRINT &DATE#
The following example assigns the current date to a script variable, and uses the default YYMMDD date format. The script prints the result (000401) in the activation report.
:SET &DATE1# = "000330"
:SET &DATE2# = ADD_DAYS(&DATE1#, 2)
:PRINT &DATE2#
The following example retrieves the current date in a format that is not the default date format for ADD_DAYS. The ADD_DAYS function retrieves the next valid work day by using the definitions made in a Calendar object that is called COMPANY. The special date format is specified in the parameters of the ADD_DAYS function.
:SET &CURDATE# = SYS_DATE("DD.MM.YY")
:SET &NWRKDAY# = ADD_DAYS("DD.MM.YY:&CURDATE#", 1, COMPANY, WORKDAY)
See also: