ADD_MONTHS
functionsupportedCore SQL functionsAdds or subtracts a specified number of months to a date or timestamp, preserving the end-of-month information.
Syntax
ADD_MONTHS( <date_or_timestamp_expr> , <num_months_expr> )
Parameters
| Name | Required | Description |
|---|---|---|
date_or_timestamp_expr | required | This is the date or timestamp expression to which you want to add a specified number of months. |
num_months_expr | required | This is the number of months you want to add. This should be an integer. It may be positive or negative. If the value is a non-integer numeric value (for example, FLOAT) the value will be rounded to the nearest integer. |
Returns
The data type of the returned value is the same as the data type of the first parameter. For example, if the input is a DATE, then the output is a DATE. If the input is a TIMESTAMP_NTZ, then the output is a TIMESTAMP_NTZ.
Usage notes
- ADD_MONTHS returns slightly different results than DATEADD used with a MONTH component: For both ADD_MONTHS and DATEADD, if the result month has fewer days than the original day, the result day of the month is the last day of the result month.
- For ADD_MONTHS only, if the original day is the last day of the month, the result day of month will be the last day of the result month.
- num_months_expr can be a positive or negative integer to either add or subtract months, respectively.