We're here to help

DateAdd

This function adds a defined number of days to a given date to create a later date value. This is useful for avoiding hardcoded values for a date in a test step, e.g. a test failing because of an Close Date being in the past.

Format: DateAdd(date,amount,unit)

There are two internal functions which are useful when managing dates:

TODAY will create a date and use the system date

NOW will create a date timestamp and use the system date

Examples:

{TODAY}– This will default to system date, e.g. 2015-01-16

{NOW}– This will default to system date and time, e.g. 2015-01-16 10:13:43.0

{DateAdd(TODAY,1)}– This will default to tomorrow, e.g. 2015-01-17

{DateAdd(TODAY,"1")}– This will default to yesterday, e.g. 2015-01-15

{DateAdd(TODAY,1,MONTH)}– This will add one month to current date, e.g. 2015-02-16

{DateAdd(NOW,"-2",HOUR)}– This will remove two hours from current datetime, e.g. 2015-01-16 08:15:27.0

Note that, if you are using a negative number, the value should be enclosed in double quotes, e.g. {DateAdd(TODAY,“-1”)}.

Practice


Want to learn more about using this function in Provar? You can use the following sample test case to get started. Simply right-click to download DateAdd.testcase and then drag and drop the test case into the test folder within the Navigator panel of Provar.

Note: You will need to unzip/extract the compressed file before using it in Provar.