pyspark.sql.functions.next_day#

pyspark.sql.functions.next_day(date, dayOfWeek)[source]#

Returns the first date which is later than the value of the date column based on second week day argument.

New in version 1.5.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters
dateColumn or str

target column to compute on.

dayOfWeekstr
day of the week, case-insensitive, accepts:

“Mon”, “Tue”, “Wed”, “Thu”, “Fri”, “Sat”, “Sun”

Returns
Column

the column of computed results.

Examples

>>> df = spark.createDataFrame([('2015-07-27',)], ['d'])
>>> df.select(next_day(df.d, 'Sun').alias('date')).collect()
[Row(date=datetime.date(2015, 8, 2))]