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

snowflake.snowpark.functions.previous_day

snowflake.snowpark.functions.previous_day(date: ColumnOrName, day_of_week: ColumnOrLiteral) 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