snowflake.snowpark.functions.date_sub

snowflake.snowpark.functions.date_sub(col: Union[Column, str], num_of_days: Union[Column, str, int])[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.26.0/snowpark-python/src/snowflake/snowpark/functions.py#L5008-L5048)

Subtracts a number of days from a date column.

Parameters:
  • col – The column to subtract from.

  • num_of_days – The number of days to subtract.

Example:

>>> from snowflake.snowpark.functions import date_sub, to_date
>>> df = session.createDataFrame([("1976-01-06")], ["date"])
>>> df = df.withColumn("date", to_date("date"))
>>> df.withColumn("date", date_sub("date", 2)).show()
--------------
|"DATE"      |
--------------
|1976-01-04  |
--------------
Copy
Language: English