Automation Engine Script Guide > Ordered by Function > Date and Time > SYS_DATE

SYS_DATE

Script Function: Returns the current date at the beginning of the scriptA particular Automation Engine object type. processing

Syntax

SYS_DATE([Date Format], [TimeZone])

Syntax

Description/Format

Date Format

Format for the retrieved date.
Format: script literal or script variable
Default: "YYMMDD"

TimeZone

Name of a TimeZone objectAutomation Engine controlled activities and processes are structured in the form of objects. See also: Task or the keyword UTC.
Format: script literal or script variableA placeholder for a value within a script.


Return code

Current date in the specified format

Comments

This script functionPre-defined run book template in the Automation Engine. One single step only, e.g. Start Windows Service, Copy file,… determines the current day's date. A TimeZone, entered as a parameter, is included.

Date Format is optional. It is used to determine the format in which the function should return values. If you do not specify Date Format, the default format "YYMMDD" is used.

TimeZone is also optional. If the script function is called without this parameter, the object's TimeZone is used, or that of the clientA closed environment within an Automation Engine system where you can create and run objects. A client name consists of a 4-digit number that must be indicated when a user logs on to the Automation Engine system. Users and their rights are also defined in clients. A particular Automation Engine object type. if none has been defined for the object itself. If a non-defined TimeZone is entered, the default value (Client's TimeZone) is used. Instead of a TimeZone, the keyword UTC may be used. The date is returned directly in UTC (Coordinated Universal Time).

The current date is determined at the beginning of the script processing and "frozen". This ensures the consistency of the script. If you use the script function repeatedly within a script, the same date will always be returned. This is especially important when the script processing for a specified time period is interrupted by a :WAIT statement.

In order to transfer the current date with the script statement :PUT_VAR to a Variable object of the type "Time stamp", you must use the date formats "YYMMDD" (Default),  "YYYYMMDD" or "YYYY-MM-DD". This format is not saved after saving to the variableIt stores or retrieves values dynamically at runtime. An individual Automation Engine object type. on the Windows platform. The display of the date is based now on the regional options in the control panel of Windows.

Examples

In the first example, the current date is retrieved and stored in a script variable. The second example shows that it is also possible to use special terms. The day of the week is retrieved while using a script variable as a function parameter.

:SET &DATE# = SYS_DATE("DD.MM.YYYY")

:SET &FORMAT# = "WW"
:
SET &WEEKDAY# = SYS_DATE(&FORMAT#)

This example shows how this function is used without specification of Date Format.

:IF SYS_DATE() = "990101"
!...

:
ENDIF

In the third example, the current date is determined and saved in a Variable object of the type "Time stamp". A TimeZone is used which has been defined for Central European Time.

:SET &DATE# = SYS_DATE("YYYY-MM-DD","TZ.MEZ")
:
PUT_VAR BOOKING.DATE, , &DATE#

 

See also:

Script element Description

CONV_DATE

Converts a date from one date format to another.
DIFF_DATE Determines the difference between two date entries in days.
SYS_DATE_PHYSICAL Returns the current date.
SYS_LDATE Returns the logical dateThe logical date is used as a comparison date for checking Calendar conditions..

Script Elements - Date and Time

Date, Time and Period Formats

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