Date and time values

You can use Expressions to generate dynamic date and time values. These values allow you to create time stamps, for instance, or to perform specific Steps on certain dates.

Generate your date and time values in one of the following ways:

RPA Studio provides on-screen descriptions and examples for date and time Expressions. This is available for Expressions you enter into Step Values.

Specify the date and time format

By default, RPA Studio creates date and time values in the format that you have defined in the Tosca settings at Project > Settings > TBox > Dynamic Temporal Expressions.

If the machine on which you create your Bots uses a different number format than your application, you can specify a different date and time format in one of the following ways:

  • In the settings or via configuration parameter as described in "Define date and number formats".

    Settings apply to all folders and Bots in your workspace. Configuration parameters only apply to the folders or Bots for which you create them.

  • Directly in the Expression for calculated or combined date and time values.

    The format you define in the Expression only applies to this particular Step. It overrides the settings as well as any configuration parameters for the Bot or folder.

Generate values based on the current date and time

To generate values that are based on the current date and time, use the syntax {COMMAND}.

The table below lists all available commands. The examples in the following two tables assume the following: 

  • The current date is June 8th, 2019. The specified date format for RPA Studio is MM-dd-yyyy.

  • The current time is 3.09 pm. The specified time format for RPA Studio is HH:mm.

  • The language specified in the Windows settings of the workstation is English.

Current date command

Result

Example

DATE

Full date

06-08-2019

TIME

Current time

15:09

DATETIME

Current time stamp

20190608150900

DAY

Current day

8

MONTH

Current month

6

YEAR

Current year

19

MONTHFIRST

First day of the current month as a complete date

06-01-2019

MONTHLAST

Last day of the current month as a complete date

06-30-2019

QUARTERFIRST

First day of the current quarter as a complete date

04-01-2019

TRIMESTERFIRST

First day of the current trimester as a complete date

05-01-2019

HYEARFIRST

First day of the current half year as a complete date

01-01-2019

You can change the values you generate with the commands DAY, MONTH, YEAR, or DATE with a prefix:

Prefix command

Result

Example

LDATE

Weekday and date in full, in the language specified in the Windows settings of your workstation.

Saturday, June 8, 2019

LDAY

Full name of the weekday, in the language specified in the Windows settings of your workstation.

Saturday

LMONTH

Full name of the month, in the language specified in the Windows settings of your workstation.

June

LYEAR

Full year (four-digit)

2019

NDAY

Current day value in double digits. Returns single-digit results with a leading zero.

08

NMONTH

Current month value in double digits. Returns single-digit results with a leading zero.

06

NYEAR

Current year value in double digits. Returns single-digit results with a leading zero.

19

ADAY

Abbreviation of the weekday name, in the language specified in the Windows settings of your workstation.

Sat

AMONTH

Abbreviation of the month name, in the language specified in the Windows settings of your workstation.

Jun

Calculate date and time values

If you don't want to use the current date or time, you can calculate a date or time. The Expression for calculated values also allows you to specify the output format.

To calculate date and time values, use the syntax {DATE[Basedate][Offset][Format]}.

You can leave parameters empty, but you always need to enter the brackets.

  • Replace Basedate with a specific date/time, or leave the parameter value empty to use the current date.

    If you add a specific base date/time, the format must be the same as in the settings (see chapter "Specify the date and time format" above).

  • Replace Offset with the desired deviation from Basedate:

    Offset

    Description

    d

    days

    w

    workdays, i.e. all weekdays except Saturday and Sunday

    M

    months

    y

    years

    h

    hour as a number from 1 to 12

    H

    hour as a number from 0 to 23

    m

    minutes

    s

    seconds

  • Replace Format with the date format you want for the generated value. If you leave the parameter empty, RPA Studio uses the format from the settings (see chapter "Specify the date and time format" above).

    The Format parameter does not work with prefix commands.

Let's say that today is February 5th, 2019. Your settings define the date format as dd-MM-yyyy.

In this case, the Expression {DATE[][+3d][]} generates the value 08-02-2019.

  • The Basedate parameter is empty, so RPA Studio uses the current date and adds three days.

  • RPA Studio uses the format specified in the settings because the Format parameter is empty.

{DATE[01.01.2019][-1y+1M][ddMMyy]} generates the value 010218.

  • RPA Studio uses the date from the Basedate parameter, deducts one year and adds one month.

  • RPA Studio formats the generated date according to the Format parameter.

Combine current and calculated values

You can also combine current date commands with calculated date and time values. This allows you to calculate a date, which the current date command then uses instead of the actual current date.

To combine commands, use the calculated value as a parameter for the current date command:

{CURRENT DATE COMMAND[{DATE[Basedate][Offset][Format]}]}

Let's say that today is March 1st, 2019. The settings define the date format as MM-dd-yyyy.

You want your Expression to return the month of a calculated date. To do so, enter {MONTH[{DATE[][+2M][]}]}.

  • The Basedate parameter is empty, so RPA Studio uses the current date and adds two months.

  • Because the Format parameter is empty, RPA Studio uses the format specified in the settings.
  • Consequently, the result of the DATE parameter is 05-01-2019.

The current date command MONTH uses this result as the current date and returns the month: 5.

You can also use custom .NET framework date and time format strings. For more information, see the Microsoft .NET documentation:

https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings and https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings.

Was this information helpful?

Tricentis RPA Studio Manual 2020.2 © Tricentis GmbH