snowflake.snowpark.functions.last_day(expr: Union[Column, str], part: Optional[Union[Column, str]] = None) Column[source]

Returns the last day of the specified date part for a date or timestamp. Commonly used to return the last day of the month for a date or timestamp.

  • expr – The array column

  • part – The date part used to compute the last day of the given array column, default is “MONTH”. Valid values are “YEAR”, “MONTH”, “QUARTER”, “WEEK” or any of their supported variations.


>>> import datetime
>>> df = session.create_dataframe([
...     datetime.datetime.strptime("2020-05-01 13:11:20.000", "%Y-%m-%d %H:%M:%S.%f"),
...     datetime.datetime.strptime("2020-08-21 01:30:05.000", "%Y-%m-%d %H:%M:%S.%f")
... ], schema=["a"])
[Row(LAST_DAY("A"), 5, 31)), Row(LAST_DAY("A"), 8, 31))]
>>>"a", "YEAR")).collect()
[Row(LAST_DAY("A", "YEAR"), 12, 31)), Row(LAST_DAY("A", "YEAR"), 12, 31))]