You are viewing documentation about an older version (1.3.0). View latest version

snowflake.snowpark.functions.add_months

snowflake.snowpark.functions.add_months(date_or_timestamp: ColumnOrName, number_of_months: Column | int) Column[source]

Adds or subtracts a specified number of months to a date or timestamp, preserving the end-of-month information.

Example

>>> import datetime
>>> df = session.create_dataframe([datetime.date(2022, 4, 6)], schema=["d"])
>>> df.select(add_months("d", 4)).collect()[0][0]
datetime.date(2022, 8, 6)
Copy