Script Function: Adds days to a given date
ADD_DAYS(Date, Days, [[Calendar], [Calendar Keyword]])
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. |
Days |
A value specifying a number of days. |
Calendar |
The name of the relevant Calendar object. |
Calendar Keyword |
The name of the relevant calendar keyword. |
Return code |
---|
Date in the specified format |
This function adds Days to a given Date. Optionally, this calculation can also be made depending on Calendar and Calendar Keyword. Only Days which have been defined in the calendar keyword will be taken into account.
If you specify a particular date format, the date will be returned in this format. Otherwise, the default formats "YYMMDD" or "YYYYMMDD" must be used and will be returned. Use a colon or semicolon as a separator between Date Format and Date.
It is also possible to specify zero Days. If the Date is valid according to the Calendar, this date will be returned. If it is not valid, the previous valid date (calendar conditions) will bereturned.
The range of the specified calendar is automatically considered in the calendar calculation. This range depends on the settings the administrator defined in the variable UC_CLIENT_SETTINGS in the keys NOW_MINUS and NOW_PLUS. The script function returns "0" if the calculated date lies beyond this defined range.
The first example adds two days to the specified date. The result ("000401") is output to the activation protocol.
:SET &DATE# = ADD_DAYS("000330", 2)
:PRINT &DATE#
In this example, the date is assigned to a script variable. The default format "YYMMDD" will be used because no date format has been specified. The result ("000401") is again output in the activation protocol.
:SET &DATE1# = "000330"
:SET &DATE2# = ADD_DAYS(&DATE#, 2)
:PRINT &DATE2#
The third example retrieves the next valid work day. This is done using the definitions made in the company calendar. As the current date was not retrieved in the default format, the special date format must again be specified in the script variable.
:SET &CURDATE# = SYS_DATE("DD.MM.YY")
:SET &NWRKDAY# = ADD_DAYS("DD.MM.YY:&CURDATE#", 1, COMPANY, WORKDAY)
See also:
Script Elements - Date and Time
About Scripts
Script Elements - Alphabetical Listing
Script Elements - Ordered by Function