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
- date
Column
or column name target column to compute on.
- date
- Returns
Column
last day of the month.
Examples
>>> from pyspark.sql import functions as sf >>> df = spark.createDataFrame([('1997-02-10',)], ['dt']) >>> df.select('*', sf.last_day(df.dt)).show() +----------+------------+ | dt|last_day(dt)| +----------+------------+ |1997-02-10| 1997-02-28| +----------+------------+
>>> df.select('*', sf.last_day('dt')).show() +----------+------------+ | dt|last_day(dt)| +----------+------------+ |1997-02-10| 1997-02-28| +----------+------------+