pyspark.sql.functions.last_day#

pyspark.sql.functions.last_day(date)[source]#

Returns the last day of the month which the given date belongs to.

New in version 1.5.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters
dateColumn or str

target column to compute on.

Returns
Column

last day of the month.

Examples

>>> df = spark.createDataFrame([('1997-02-10',)], ['d'])
>>> df.select(last_day(df.d).alias('date')).collect()
[Row(date=datetime.date(1997, 2, 28))]