Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

TIME

Example

Retrieve the time component from a given time expression.

SELECT TIME(“19:30:10”);

Definition and Usage

The TIME() function extracts the time portion from a provided datetime expression.

Note: If the expression is not a datetime or time, it returns “00:00:00”, or NULL if the expression itself is NULL.

Syntax

TIME(expression)

Parameter Values

Parameter

Description

datetime

Required: The time or datetime from which to extract the time component

Technical Details

Works in:

 From MySQL version 4.0

More Examples

Example

Retrieve the time component from the datetime expression.

SELECT TIME(“2017-08-15 19:30:10”);

Example

Extract the time portion from the given datetime expression.

SELECT TIME(“2017-08-15 19:30:10.000001”);

Example

When applied to NULL, extracting the time part does not yield a valid result.

SELECT TIME(NULL);