A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.snowflake.com/en/sql-reference/functions/add_months below:

Website Navigation


ADD_MONTHS | Snowflake Documentation

ADD_MONTHS

Adds 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> )

Copy

Arguments

Required:

date_or_timestamp_expr

This is the date or timestamp expression to which you want to add a specified number of months.

num_months_expr

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 Examples

Add 2 months to a date and cast the date to a timestamp with no time zone:

SELECT ADD_MONTHS('2016-05-15'::timestamp_ntz, 2) AS RESULT;
+-------------------------+
| RESULT                  |
|-------------------------|
| 2016-07-15 00:00:00.000 |
+-------------------------+

Copy

Demonstrate preservation of end-of-month information:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4