SYS_DATE

Use the SYS_DATE script function to retrieve the current date. The script function returns the date at the beginning of script processing, and freezes that date for the rest of the processing.

Tip: Use SYS_DATE_PHYSICAL to retrieve the current date at the actual time of processing.

Syntax

SYS_DATE ([Date format][,Time Zone|UTC])

Parameters

  • SYS_DATE
    Returns the current date at the start of processing

  • Date format
    (Optional) Date format for the retrieved date
    For more information, see Date, Time and Period Formats in Scripts.
    Format: script literal or script variable
    Default: YYMMDD

  • Time Zone or UTC
    (Optional) Specifies the time zone for the date
    Format: script literal or script variable
    Allowed values:

    • Name of a Time Zone object
      For more information, see Time Zone (TZ).
      Format: script literal or script variable
    • UTC
      Returns the date in UTC (Coordinated Universal Time)

Notes:

  • The Time Zone defined in the object attributes applies, unless you specify a different Time Zone.
  • If the object has no defined Time Zone, or if you specify a non-defined Time Zone object, then the Time Zone defined for the Client applies.
  • The retrieved date remains the same, even when you use the script function multiple times within a script. Consistency is especially important when script processing is interrupted with a :WAIT script statement.

Important! When you use a :PUT_VAR script statement to transfer the current date to a VARA object that has the data type timestamp, use one of the following date formats:

  • YYMMDD (default)
  • YYYYMMDD
  • YYYY-MM-DD

Note: (Windows only) The date format is not saved after saving to the VARA object. The displayed date format is determined by the regional options defined in the control panel of Windows.

Examples

In the following example, the script retrieves the current date and specifies a date format. The retrieved date is stored in a script variable

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

The following example specifies a calendar week date format to retrieve the current day of the week.

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

The following example does not specify a date format. The script uses the current date in the default YYMMDD format to define a condition.

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

:
ENDIF

The following example retrieves the current date and stores the value in a VARA object that has the data type timestamp. The script uses a Time Zone object that is configured for Central European Time.

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

See also: