snowflake.snowpark.functions.add_months¶

snowflake.snowpark.functions.add_months(date_or_timestamp: Union[Column, str], number_of_months: Union[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