Date and time values

Value expressions let you auto-generate dynamic values at runtime, based on your specifications. They help you to automate important processes and reduce test design and maintenance efforts.

To generate date and time values, you can choose from the following expressions:

  • Current date/time expressions create values based on the actual date/time of the test run. Use this expression whenever the actual date is important for your test. For example, to create time stamps for tracking purposes.

  • Calculated date/time expressions create fictitious dates based on the actual date of the test run or a specified date. Use this expression whenever the current date doesn't work for your test. For example, to populate a field that requires dates which are X months in the future.

  • A combination of the two calculates a fictitious date and then pretends it's the current one at the time of the test run. Use these values whenever you want to use a current date/time expression, but not the actual date of the test run. For example, to test your application's task processing.

Use the current date/time

To generate a value that's based on the actual date/time of the test run, use the syntax {Base command} or {Prefix command}:

  • Replace {Base command} with any of the available base commands.

  • Replace {Prefix command} with any of the available prefix commands. These types of commands change the values you generate with the base commands DAY, MONTH, YEAR, or DATE.

A few base commands, to generate current date/time values.

Let's say that the day of your test run is June 8th, 2025. The time is 3:09 PM.

In this case, these expressions generate these values:

  • {DATE} generates 08.06.2025.

  • {MONTH} generates 6.

  • {DATETIME} generates 20250608150900.

  • {TRIMESTERFIRST} generates 01.05.2025.

A few prefix commands, to generate current date/time values.

Let's stick with the date/time assumptions from the previous example. Also, the language specified in the Region settings of your workstation is English.

In this case, these expressions generate these values:

  • {NMONTH} generates 06.

  • {LYEAR} generates 2025.

  • {ADAY} generates Sun.

Use a calculated date/time

To generate a value that's a fictitious date, use the syntax {DATE[Basedate][Offset][Format]}:

  • Replace Basedate with a specific date/time, or leave the parameter empty to use the actual date of the test run. If you add a specific date/time, you have to use the standard DATE format.

  • Replace Offset with the desired deviation from the base date.

  • Replace Format with the desired date format of the generated value, or leave the parameter empty to use the standard DATE format.

Generate a value based on the current date, in the default format.

Let's say that today is Wednesday, February 7th, 2024.

In this case, the expression {DATE[][+4d][]} generates the value 11.02.2024.

  • The Basedate parameter is empty, so Tosca Cloud takes the current date and adds four days.

  • The Format parameter is empty, so Tosca Cloud uses the standard DATE format.

Generate a value based on the current date, in a specific format.

Let's keep pretending it's Wednesday, February 7th, 2024. And while we're at it, let's say it's 5:00 PM.

In this case, the expression {DATE[][+4w-5h][yyyyMMddHHmm]} generates the value 202402131200.

  • The Basedate parameter is empty, so Tosca Cloud takes the current date, adds four work days, and deducts 5 hours.

  • Tosca Cloud formats the generated date according to the Format parameter.

Generate a value based on a given date, in a specific format.

The expression {DATE[01.03.2024][-1y+1M][MM/dd/yy]} generates the value 04/01/23.

  • Tosca Cloud uses the date from the Basedate parameter, deducts one year and adds one month.

  • Tosca Cloud formats the generated date according to the Format parameter.

Use a combination date/time

To generate a value that lets you treat a fictitious date as the current date of the test run, use the syntax {Current date command[{DATE[Basedate][Offset][Format]}]}:

Use a combined date/time command.

Let's say that today is March 1st, 2024.

You want your expression to return the month of a calculated date, in double digits. So, you enter {NMONTH[{DATE[][+2M][]}]}:

  • The result of the DATE syntax is 01.05.2024.

  • The current date command NMONTH uses this result as the current date and returns the month: 05.

Understand date and time formats

By default, Tosca Cloud creates date and time values in the following formats: dd.MM.yyyy, HH:mm, yyyyMMddHHmmss.

To change the default values, you can use the following special task parameters in your test case: ToscaDateFormat, ToscaTimeFormat, ToscaDateTimeFormat.