pyspark.sql.functions.add_months

pyspark.sql.functions.add_months(start, months)[source]

Returns the date that is months months after start

New in version 1.5.0.

Examples

>>> df = spark.createDataFrame([('2015-04-08',)], ['dt'])
>>> df.select(add_months(df.dt, 1).alias('next_month')).collect()
[Row(next_month=datetime.date(2015, 5, 8))]