SECOND Function - SQL


Overview


The SECOND function in SQL extracts the second part from a time or datetime expression. It is useful for retrieving the second component of a time.

Example:

SELECT SECOND('2000-01-01 07:12:33')

Syntax:

SELECT SECOND(time)

time is the time or datetime from which you want to extract the minute.


Example: Time Hard-coded value


In this example, we are returning the seconds for the time ‘07:12:33,’ for a final output of 33.


Example: Datetime Hard-coded value


In this example, we are returning the seconds for the datetime ‘2000-01-01 07:12:33,’ for a final output of 33.