MySQL SECOND() Function

The SECOND() function in MySQL extracts the seconds component from a time or datetime value. This is useful for working with time data, and for performing time-based analysis or filtering.



SECOND(): Definition and Usage

SECOND() is a very handy function for isolating the seconds part of a time or datetime. You might use it to analyze events based on the seconds, create detailed time logs, or filter your data based on particular second intervals. The function returns an integer between 0 and 59 (inclusive).

Syntax

Syntax

SECOND(datetime)
      

Parameter Values

Parameter Description
datetime The time or datetime value. This is required.

Examples

Extracting Seconds from a DATETIME Value

This example shows extracting the seconds from a datetime value.

Syntax

SELECT SECOND("2017-06-20 09:34:00.000023");
      
Output

0
      

Extracting Seconds from a TIME Value

Extracting the seconds from a time value.

Syntax

SELECT SECOND("23:59:59");
      
Output

59