pyspark.sql.functions.quarter

pyspark.sql.functions.quarter(col: ColumnOrName) → pyspark.sql.column.Column[source]

Extract the quarter of a given date as integer.

New in version 1.5.0.

Examples

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