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

snowflake.snowpark.functions.date_sub

snowflake.snowpark.functions.date_sub(col: Union[Column, str], num_of_days: Union[Column, str, int])[source]

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