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 a Close Date was in the past.
Format: DateAdd(date,amount,unit)
There are two internal functions which are useful when managing dates:
- TODAY will create a date using the GMT time zone.
- NOW will create a date timestamp using the GMT zone.
Examples:
{TODAY}
– This will create a date using the GMT zone, e.g., 2015-01-16
{NOW}
– This will create a date timestamp using the GMT zone, 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 the current date, e.g. 2015-02-16
{DateAdd(NOW,"-2",HOUR)}
– This will remove two hours from the current date and time, e.g. 2015-01-16 08:15:27.0
Note: 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 Automation? 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 Automation.
Note: Unzip/extract the compressed file before using it in Automation.
- Provar Automation
- Installing Provar Automation
- Updating Provar Automation
- Using Provar Automation
- API Testing
- Behavior-Driven Development
- Creating and Importing Projects
- Creating Test Cases
- Custom Table Mapping
- Functions
- Debugging Tests
- Defining a Namespace Prefix on a Connection
- Defining Proxy Settings
- Environment Management
- Exporting Test Cases into a PDF
- Exporting Test Projects
- Override Auto-Retry for Test Step
- Managing Test Steps
- Namespace Org Testing
- NitroX
- Provar Desktop
- Provar Test Builder
- Refresh and Recompile
- Reintroduction of CLI License Check
- Reload Org Cache
- Reporting
- Running Tests
- Searching Provar with Find Usages
- Secrets Management and Encryption
- Setup and Teardown Test Cases
- Tags and Service Level Agreements (SLAs)
- Test Cycles
- Test Plans
- Testing Browser Options
- Tooltip Testing
- Using the Test Palette
- Using Custom APIs
- Callable Tests
- Data-Driven Testing
- Page Objects
- Block Locator Strategies
- Introduction to XPaths
- Creating an XPath
- JavaScript Locator Support
- Label Locator Strategies
- Maintaining Page Objects
- Mapping Non-Salesforce fields
- Page Object Operations
- ProvarX™
- Refresh and Reselect Field Locators in Test Builder
- Using Java Method Annotations for Custom Objects
- Applications Testing
- Provar Manager
- DevOps
- Introduction to Test Scheduling
- Apache Ant
- Configuration for Sending Emails via the Automation Command Line Interface
- Continuous Integration
- AutoRABIT Salesforce DevOps in Provar Test
- Azure DevOps
- Running a Provar CI Task in Azure DevOps Pipelines
- Configuring the Automation secrets password in Microsoft Azure Pipelines
- Parallel Execution in Microsoft Azure Pipelines using Multiple build.xml Files
- Parallel Execution in Microsoft Azure Pipelines using Targets
- Parallel execution in Microsoft Azure Pipelines using Test Plans
- Bitbucket Pipelines
- CircleCI
- Copado
- Docker
- Flosum
- Gearset DevOps CI/CD
- GitHub Actions
- Integrating GitHub Actions CI to Run Automation CI Task
- Remote Trigger in GitHub Actions
- Parameterization using Environment Variables in GitHub Actions
- Parallel Execution in GitHub Actions using Multiple build.xml Files
- Parallel Execution in GitHub Actions using Targets
- Parallel Execution in GitHub Actions using Test Plan
- Parallel Execution in GitHub Actions using Job Matrix
- GitLab Continuous Integration
- Travis CI
- Jenkins
- Execution Environment Security Configuration
- Provar Jenkins Plugin
- Parallel Execution
- Running Provar on Linux
- Reporting
- Salesforce DX
- Git
- Team Foundation Server
- Version Control
- Salesforce Testing
- Best Practices
- Troubleshooting
- Release Notes