snowflake.snowpark.functions.months_between¶
- snowflake.snowpark.functions.months_between(date1: Union[Column, str], date2: Union[Column, str]) Column [source] (https://github.com/snowflakedb/snowpark-python/blob/v1.26.0/snowpark-python/src/snowflake/snowpark/functions.py#L4254-L4273)¶
Returns the number of months between two DATE or TIMESTAMP values.
Example:
>>> import datetime >>> df = session.create_dataframe([[ ... datetime.datetime.strptime("2020-05-01 13:11:20.000", "%Y-%m-%d %H:%M:%S.%f"), ... datetime.datetime.strptime("2020-08-21 01:30:05.000", "%Y-%m-%d %H:%M:%S.%f") ... ]], schema=["a", "b"]) >>> df.select(months_between("a", "b")).collect() [Row(MONTHS_BETWEEN("A", "B")=Decimal('-3.629452'))]