MySQL SECOND() Function

In MySQL, the SECOND() function extracts and returns the second part of a time.

SECOND() Syntax

Here is the syntax of MySQL SECOND() function:

SECOND(time)

Parameters

time
Required. A time or datetime expression.

Return value

The MySQL SECOND() function extracts and returns the second part of a time. It returns a number in the range from 0 to 59.

The SECOND() function will return NULL if the argument is NULL.

SECOND() Examples

Here are some examples of the SECOND() function.

SELECT
    SECOND('10:11:12'),
    SECOND('2022-02-28 10:11:12');
+--------------------+-------------------------------+
| SECOND('10:11:12') | SECOND('2022-02-28 10:11:12') |
+--------------------+-------------------------------+
|                 12 |                            12 |
+--------------------+-------------------------------+