> ## Documentation Index
> Fetch the complete documentation index at: https://www.integrate.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# ETL: AddToDate

> Add or subtract years, months, days, hours, minutes, or seconds from a datetime value in Integrate.io ETL expressions for date arithmetic.

## Description

Returns the result of adding a signed integer amount of a calendar unit to a datetime value. A negative amount subtracts.

Use `AddToDate` when you need number-and-part datetime arithmetic (for example, add 3 months, subtract 15 minutes). For ISO 8601 duration strings, use [AddDuration](/etl/addduration).

Month arithmetic clamps to the last valid day of the target month, so `AddToDate(ToDate('2020-01-31'), 1, 'MM')` returns the last day of February.

## Syntax

`AddToDate(datetime, amount, datepart)`

## Arguments

* *datetime* - datetime expression.
* *amount* - integer number of units to add. Negative values subtract.
* *datepart* - string identifying the calendar unit. Case-sensitive. One of:

  | Token  | Unit    |
  | ------ | ------- |
  | `yyyy` | Years   |
  | `MM`   | Months  |
  | `dd`   | Days    |
  | `HH`   | Hours   |
  | `mm`   | Minutes |
  | `ss`   | Seconds |

  The tokens match `SimpleDateFormat` letters exactly. `MM` (months) and `mm` (minutes), and `HH` (hours) and `hh`, differ only in case, so tokens like `DD` or `Mm` are rejected rather than guessed.

## Examples

* `AddToDate(ToDate('2020-01-15T00:00:00Z'), 3, 'MM')` returns `2020-04-15T00:00:00.000Z`
* `AddToDate(ToDate('2020-01-31T00:00:00Z'), 1, 'MM')` returns `2020-02-29T00:00:00.000Z`
* `AddToDate(ToDate('2020-01-15T12:00:00Z'), -30, 'mm')` returns `2020-01-15T11:30:00.000Z`
* `AddToDate(ToDate('2020-01-15T00:00:00Z'), 10, 'dd')` returns `2020-01-25T00:00:00.000Z`

## Return value datatype

datetime

## Impact of null value

If *datetime*, *amount*, or *datepart* is null, returns null. If the *datepart* is a non-null value that does not match one of the tokens above, or the call has fewer than three arguments, an exception is thrown.
