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 calendarAn Automation Engine object type that defines a set of days based on calendar keywords.. |
Calendar Keyword |
The name of the relevant calendar keywordThe attribute of a Calendar object that defines which days included in the calendar.. |
Return code |
---|
Date in the specified format |
This functionPre-defined run book template in the Automation Engine. One single step only, e.g. Start Windows Service, Copy file,… 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 variableIt stores or retrieves values dynamically at runtime. An individual Automation Engine object type. 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 userIn the Automation Engine, a user is an instance of a User object, and generally the user is a specific person who works with Automic products. The User object is assigned a user ID and then a set of access rights to various parts of the Automation Engine system and product suite. These access rights come in the form of Automation Engine authorizations and privileges, Decision user roles and EventBase rights and ARA web application object rights. You can manage all these centrally in the ECC user management functions. See also, Unified user management. 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
Automic Documentation - Tutorials - Automic Blog - Resources - Training & Services - Automic YouTube Channel - Download Center - Support |
Copyright © 2016 Automic Software GmbH |