MySQL SECOND() Function

MySQL | SECOND() Function: Learn about the SECOND() function, how it works, its usages, syntax, and examples.
Submitted by Apurva Mathur, on October 11, 2022

SECOND() Function

The SECOND() function is used to get the seconds part from the given datetime value. It only fetches the seconds and then displays it as a result, the rest other parts of the datetime value are ignored by this function.

SECOND() Syntax

SELECT SECOND(datetime value);

SECOND() Parameter(s)

It takes only one parameter which is datetime value.

SECOND() Return Value

As a result, it will display the second part from the time that you have provided.

MySQL SECOND() Function Example 1

SELECT SECOND('2019-12-06 12:11:45.009');
Example 1: MySQL SECOND() Function

MySQL SECOND() Function Example 2

SELECT SECOND('19:11:04.009');
Example 2: MySQL SECOND() Function

MySQL SECOND() Function Example 3

SELECT SECOND('19:11:000897.009');
Example 3: MySQL SECOND() Function

if the datetime value which you are writing as a parameter doesn't include any second part of the time and is invalid then in such case, it will show you 0 or NULL.




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.