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

snowflake.snowpark.functions.previous_day

snowflake.snowpark.functions.previous_day(date: Union[Column, str], day_of_week: Union[Column, None, bool, int, float, str, bytearray, Decimal, date, datetime, time, bytes, NaTType, float64, list, tuple, dict]) Column[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.16.0/src/snowflake/snowpark/functions.py#L3432-L3449)

Returns the date of the first specified DOW (day of week) that occurs before the input date.

Example:

>>> import datetime
>>> df = session.create_dataframe([
...     (datetime.date.fromisoformat("2020-08-01"), "mo"),
...     (datetime.date.fromisoformat("2020-12-01"), "we"),
... ], schema=["a", "b"])
>>> df.select(previous_day("a", col("b"))).collect()
[Row(PREVIOUS_DAY("A", "B")=datetime.date(2020, 7, 27)), Row(PREVIOUS_DAY("A", "B")=datetime.date(2020, 11, 25))]
>>> df.select(previous_day("a", "fr")).collect()
[Row(PREVIOUS_DAY("A", 'FR')=datetime.date(2020, 7, 31)), Row(PREVIOUS_DAY("A", 'FR')=datetime.date(2020, 11, 27))]
Copy
Language: English