Dynamic date and time expressions
Tosca TBox allows date and time expressions to be dynamically generated. You can use various dynamic expressions which can be combined according to a specific syntax.
Tosca TBox provides on-screen descriptions for dynamic values, including date and time expressions.
Click into the respective Value field. When you open the curly brackets by pressing the { key, a drop-down list appears.
Navigate through the list with the ↑ and ↓ keys to see a brief description as well as an example of the chosen value.
Drop-down list and brief description of dynamic value
Using current date and time values
The following dynamic expressions use the current date and time as base values.
The examples provided in the table below use December 30th, 2015 (30.12.2015) and 3:09pm (15:09:00) as base values:
Expression |
Description |
Example |
---|---|---|
{DATE} |
Full date |
30.12.2015 |
{TIME} |
Current time |
15:09 |
{DATETIME} |
Current time stamp |
20151230150900 |
{DAY} |
Current day |
30 |
{MONTH} |
Current month |
12 |
{YEAR} |
Current year (two-digit) |
15 |
{MONTHFIRST} |
First day of the current month as a complete date |
01.12.2015 |
{MONTHLAST} |
Last day of the current month as a complete date |
31.12.2015 |
{QUARTERFIRST} |
First day of the current quarter as a complete date |
01.10.2015 |
{TRIMESTERFIRST} |
First day of the current trimester as a complete date |
01.09.2015 |
{HYEARFIRST} |
First day of the current half year as a complete date |
01.07.2015 |
Results can be formatted as described in chapter "Defining date and time formats".
Formats for the expressions DAY, MONTH, YEAR or DATE can be altered with a prefix.
Description |
Example |
|
---|---|---|
{LDATE},{LDAY},{LMONTH},{LYEAR} |
Date, day, month or year, according to the system settings that are currently valid |
{LDATE} = Monday, December 30, 2015 {LDAY} = Monday {LMONTH} = December {LYEAR} = 15 |
{NDAY},{NMONTH},{NYEAR} |
Day, month and year are always entered in double figures. Single digit results are returned with a leading zero digit. |
{NDAY} = 30 {NMONTH} = 12 {NYEAR} = 15 |
{ADAY},{AMONTH} |
Day values are shown with the first two letters and month values with the first three letters. |
{ADAY} = Mo {AMONTH} = Dec |
Calculating and formatting date and time values
Date and time values can be calculated by using the base date along with deviations, and you can display them in a user-defined format.
Syntax: |
{<EXPRESSION>[<Basedate>][<Offset>][<Format>]} |
The <EXPRESSION> indicates the information to be shown. See also chapter "Using current date and time values" above for further information on possible values.
Please make sure to specify all parameters subsequent to <Expression>. Parameter values can be left empty provided that the square brackets remain. In case you are using an expression with a prefix, omit the <Format> parameter including the surrounding square brackets. |
Parameter |
Description |
---|---|
Basedate |
Date value in Tosca date format (see chapter "Tosca date formats") |
Offset |
Deviation from the <Basedate> (see chapter "Calculating dates from the base date"). |
Format |
Date expression format of the test object (see chapter "Defining date and time formats"). Omit this parameter if expressions from the "Prefix" table are used. |
In the following example, the current month is identified using the standard format settings. {DATE[][][MM.yyyy]} The expression determines the current date without any deviations. This is why the first two parameters are left empty. The formatted result indicates month and year. If the current date is 23.05.2016, the result is as follows: 05.2016. |
In the example below, a dynamic ID receives a timestamp element. If the current date is 15.02.2015, the Id expression equals account_maintenance_15022015.
|
Calculating dates from the base date
Dates can be calculated starting from the base date. As a result, Offsets will either be added or deducted. The following table contains all the possible values. Please take care of notations and make sure not to use any spaces.
Unit |
Description |
---|---|
d |
days |
w |
workdays; this includes all weekdays except for Saturdays, Sundays, and user-defined holidays |
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 |
fff |
milliseconds |
The expression +3M-1d means that three months are added to the base date and one day is deducted. {DATE[23.05.2016][+3M-1d][]} The expression above returns the following result: 22.08.2016. |
Defining date and time formats
The format for date and time expressions can be specified on the following levels:
-
Definition of the format parameter in the dynamic expression of the Value column (see chapter "Calculating and formatting date and time values")
-
Definition as a test configuration parameter: The test configuration parameter name matches the formats used in the Settings dialog without any spaces.
Test configuration parameter with date and time formats
-
Definition in the Settings dialog: here you can specify Tosca date formats and formats used for date expressions in the test object.
The order of the specified list matches the priority of the used expressions.
You can also use custom date and time format strings of the .Net framework for the format. Please click on the links below for further information on the syntax: 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. |
To calculate working days, Tricentis Tosca requires information on the national holidays in the particular country.
You can freely define national holidays in the Settings dialog under Settings->TBox->Special Dates (see chapter "Settings - Special Dates").