pyspark.sql.functions.last_day

pyspark.sql.functions.last_day(date: ColumnOrName) → pyspark.sql.column.Column

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

Examples

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