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

snowflake.snowpark.functions.months_between¶

snowflake.snowpark.functions.months_between(date1: ColumnOrName, date2: ColumnOrName) → Column[source]¶

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'))]
Copy