Script Function: Subtracts days from a given date
SUB_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. |
Calendar Keyword |
The name of the relevant calendar keyword. |
Return code |
---|
Date in the specified format |
This function subtracts Days from a given Date. Optionally, you may execute these functions depending on Calendar and Calendar Keyword. In this case only Days which are valid due to the relevant calendar definitions will be taken into account.
If you specify a particular data format, the date will be returned in this format. If no date format has been specified, use the default formats "YYMMDD" or "YYYYMMDD" and the date will be returned in the corresponding format. 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 calendar calculations. This range depends on the settings the administrator defined in the variable UC_CLIENT_SETTINGS in the keys NOW_MINUS and NOW_PLUS. Code "0" will be returned if the calculated date lies beyond this defined range".
The first example subtracts two days from a specified date. The result ("000330") is output in the activation protocol.
:SET &DATE# = SUB_DAYS("000401", 2)
:PRINT &DATE#
The second example queries the number of days to be stored by the user using a script statement. This function deducts the retrieves number from the current date and stores the result in a script variable. The default format "YYMMDD" is used because no date format has been specified.
:SET &CURDATE# = SYS_DATE()
:READ &NUMBER#,"00","Store how many days?","08",N
:SET &RETDATE# = SUB_DAYS(&CURRENTDATE#, &NUMBER#)
The third example calculates the current date. Two days are then deducted from this date. As it was not retrieved in the default format, the required date format must again be specified in the script variable.
:SET &CURDATE# = SYS_DATE("DD.MM.YY")
:SET &PWRKDAY# = SUB_DAYS("DD.MM.YY:&CURDATE#", 2)
See also:
Script Elements - Date and Time
About Scripts
Script Elements - Alphabetical Listing
Script Elements - Ordered by Function