pyspark.sql.functions.month

pyspark.sql.functions.month(col: ColumnOrName) → pyspark.sql.column.Column

Extract the month of a given date as integer.

Examples

>>> df = spark.createDataFrame([('2015-04-08',)], ['dt'])
>>> df.select(month('dt').alias('month')).collect()
[Row(month=4)]