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.16.0/src/snowflake/snowpark/functions.py#L4174-L4203)¶
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 | --------------