Nexial Automation

Test Automation Platform for everyone!

X

$(date)

Description

This built-in function provides basic operation to manipulate date such add “adding day”, “setting hour”. This built-in function assumes the date parameter in the standard US date format (i.e. MM/dd/yyyy HH:mm:ss). You might want to consider using $(date|stdFormat|date|fromFormat) or $(date|format|date|fromFormat|toFormat) functions to derive the appropriate format first before invoking other date-operational functions.

Date Format

For date/time formatting (denoted below as format or *Format), Nexial supports the following 3 conventions:

  • Standard Java date/time formatting convention for a full range to express the desired date/time format.
  • epoch  for timestamp. Use epoch to signify the display of date/time value in its epoch value (millisecond).
  • informal to express date/time information in a colloquial, non-exact manner that mimic human conversation. For example, informal format would output about a minute ago instead of 00:00:57, or about a month and a half ago rather than 2018/08/24 00:01:32. The informal format is suitable to use in conjunction with the sound » speak(text) command.
  • base10time to express time information as a base-10 decimal number. For example, 10:25:30 would be converted as 10.425, 14.32918 would be converted as 14:19:46.

Available Functions

$(date|stdFormat|date|fromFormat)

Convert a date from fromFormat to the standard format (i.e. MM/dd/yyyy HH:mm:ss).

Example
Script:
script

Output:
output


$(date|format|date|fromFormat|toFormat)

Convert a date from the specified fromFormat to the specified toFormat. Check out above links for date format.

Example
Script:
script

Output:
output


$(date|addYear|date|years)

Add years to date. Use negative value to denote the “subtract” intent. The specified date is assumed in standard format (MM/dd/yyyy HH:mm:ss).

Example
Script:
script

Output:
output


$(date|addMonth|date|months)

Add months to date. Use negative value to denote the “subtract” intent. The specified date is assumed in standard format (MM/dd/yyyy HH:mm:ss).

Example
Script:
script

Output:
output


$(date|addDay|date|days)

Add days to date. Use negative value to denote the “subtract” intent. The specified date is assumed in standard format (MM/dd/yyyy HH:mm:ss).

Example
Script:
script

Output:
output


$(date|addHour|date|hours)

Add hours to date. Use negative value to denote the “subtract” intent. The specified date is assumed in standard format (MM/dd/yyyy HH:mm:ss).

Example
Script:
script

Output:
output


$(date|addMinute|date|minutes)

Add minutes to date. Use negative value to denote the “subtract” intent. The specified date is assumed in standard format (MM/dd/yyyy HH:mm:ss).

Example
Script:
script

Output:
output


$(date|addSecond|date|seconds)

Add seconds to date. Use negative value to denote the “subtract” intent. The specified date is assumed in standard format (MM/dd/yyyy HH:mm:ss).

Example
Script:
script

Output:
output


$(date|diff|date1|date2|precision)

Find the absolute difference between 2 dates (date1 and date2) and return such value in the specified date precision. The possible values of precision are YEAR, MONTH, WEEK, DAY, HOUR, MINUTE, SECOND and MILLISECOND. The specified dates (date1 and date2) are assumed in standard format (MM/dd/yyyy HH:mm:ss).

Example
Script:
script

Output:
output


$(date|setYear|date|years)

Set the year portion of date to the specified years. The specified date is assumed in standard format (MM/dd/yyyy HH:mm:ss).

Example
Script:
script

Output:
output


$(date|setMonth|date|months)

Set the month portion of date to the specified months. The specified date is assumed in standard format (MM/dd/yyyy HH:mm:ss).

Example
Script:
script

Output:
output


$(date|setDay|date|days)

Set the day portion of date to the specified days. The specified date is assumed in standard format (MM/dd/yyyy HH:mm:ss).

Example
Script:
script

Output:
output


$(date|setHour|date|hours)

Set the hour portion of date to the specified hours. The specified date is assumed in standard format (MM/dd/yyyy HH:mm:ss).

Example
Script:
script

Output:
output


$(date|setMinute|date|minutes)

Set the minute portion of date to the specified minutes. The specified date is assumed in standard format (MM/dd/yyyy HH:mm:ss).

Example
Script:
script

Output:
output


$(date|setSecond|date|seconds)

Set the second portion of date to the specified seconds. The specified date is assumed in standard format (MM/dd/yyyy HH:mm:ss).

Example
Script:
script

Output:
output


$(date|setDOW|date|day)

Derive the “day of the week” for a given date. The specified date is assumed in standard format (MM/dd/yyyy HH:mm:ss or MM/dd/yyyy). Use the days parameter to set the day of the week. As a convenience, both 0 and 7 represent Sunday, while 6 represents Saturday. Since there are only 7 days in a week, any integer value outside the range of 0 through 7 would be considered as value. For example, March 21th 2013 is a Thursday. $(date|setDOW|03/21/2013|1) would yield 03/18/2013, which is a Monday.

Example
Script:
script

Output:
output


See Also