Mysql Second Function

MySQL: SECOND Function

This tutorial explains how to use the MySQL SECOND function with syntax and examples.

Description

The MySQL SECOND function returns the second portion of a date value.

Syntax

The syntax for the SECOND function in MySQL is:

SECOND( date_value )

Parameters or Arguments

date_value

A time or datetime value from which to extract the seconds.

Note

Applies To

The SECOND function can be used in the following versions of MySQL:

  • MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23

Example

Let's look at some MySQL SECOND function examples and explore how to use the SECOND function in MySQL.

For example:

mysql> SELECT SECOND('2014-01-28 07:47:18.000004');
Output: 18

mysql> SELECT SECOND('2014-01-28 15:21:05');
Output: 5

mysql> SELECT SECOND('12:13:06');
Output: 6

mysql> SELECT SECOND('838:11:59');
Output: 59

This last SECOND example would display the second portion of the current system time (current system time is returned by the CURTIME function).

mysql> SELECT SECOND(CURTIME());