> ## Documentation Index
> Fetch the complete documentation index at: https://help.nextmatter.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Date calculations

> Find out how to calculate a date or a batch of dates in your Next Matter workflow.

<Tip>
  **Good to know:** Check out our ready-made templates available when you add a step and select **Templates > Next Matter templates**. You can use the templates to create a set of pre-configured steps.
</Tip>

1. Open your workflow and create a form step with the two form fields. Click **+ Add form field** and create the following:

   * **Date**: The date when you want to apply the calculation. This will be the form field one.
   * **Short text**: This is to submit the days that you want to add/subtract when running your workflow. This will be the form field two.

   <Info>
     To subtract days, enter a negative number such as -5. For adding days simply type the number.
   </Info>
2. Now create the date calculation step. To do that, create an integration step after step 1.
3. Click **Settings** to configure the step. Enter the following details:

* **Method**: POST
* **URL**: `https://integrations.nextmatter.com/g/utils/calculatedate`
* **Headers**: Content-Type: application/json
* **Body** might look like the following:

<Accordion title="Single date example">
  <CodeGroup>
    ```json theme={null}
    {  
      "date": "<DATE>",  
      "days_to_add": "<NUMBER OF DAYS>",  
      "enable_business_days": "<TRUE or FALSE>"  
    }
    ```
  </CodeGroup>

  **date**: Enter the date by using the data reference of the date form field from the previous step.

  **days\_to\_add**: Number of days to add or remove. To remove, add a minus, for example, -5

  **enable\_business\_days**: Optional. If set to true, the calculation skips Saturday and Sunday. Adding 1 day to a Friday leads to the next Monday. This feature is not available when removing dates. It will return an error if **days\_to\_add** is negative, and **enable\_business\_days** is set to true.

  For example:

  <CodeGroup>
    ```json theme={null}
    { 
      "date": "2022-07-01", 
      "days_to_add": 1, 
      "enable_business_days": true
    }
    ```
  </CodeGroup>

  In reality, **Body** might look like the following:

  <CodeGroup>
    ```json theme={null}
    {
      "date": "{1. Enter Date Info - Choose initial date - Date}",
      "days_to_add": "{1. Enter Date Info - Choose days to add. Use a minus if you want to substract days. - Input}"
    }
    ```
  </CodeGroup>
</Accordion>

<Accordion title="Batch of single dates example">
  Your batch might look like the following:

  <CodeGroup>
    ```json theme={null}
    [
      { 
        "date": "2022-05-01", 
        "days_to_add": 1, 
        "enable_business_days": true
      },
      { 
        "date": "2022-06-01", 
        "days_to_add": -5, 
        "enable_business_days": false
      },
      { 
        "date": "2022-06-01", 
        "days_to_add": 2
      }
    ]
    ```
  </CodeGroup>
</Accordion>

* In the **Results to be used in later steps**, click **Add variable**.

  You need to create a variable for every date set so that the resulting date can be referenced in later steps.

  * For one date set, add the `calculatedDate` variable with the value of `$.date`
  * For multiple sets, your variables might be the following:

  | Name            | Value       |
  | --------------- | ----------- |
  | calculatedDate1 | \$\[0].date |
  | calculatedDate2 | \$\[1].date |
  | calculatedDate3 | \$\[2].date |
