snowflake.snowpark.functions.add_months¶
- snowflake.snowpark.functions.add_months(date_or_timestamp: Union[Column, str], number_of_months: Union[Column, int]) Column [source] (https://github.com/snowflakedb/snowpark-python/blob/v1.26.0/snowpark-python/src/snowflake/snowpark/functions.py#L579-L594)¶
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)