You are viewing documentation about an older version (1.12.1). 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, list, tuple, dict]) Column[source]

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