pyspark.sql.functions.second

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

Extract the seconds of a given date as integer.

Examples

>>> import datetime
>>> df = spark.createDataFrame([(datetime.datetime(2015, 4, 8, 13, 8, 15),)], ['ts'])
>>> df.select(second('ts').alias('second')).collect()
[Row(second=15)]