This tutorial explains how to use the MySQL TIME function with syntax and examples.
The MySQL TIME function extracts the time value from a time/datetime expression.
The syntax for the TIME function in MySQL is:
TIME( expression )
The time or datetime value from which the time should be extracted.
The TIME function can be used in the following versions of MySQL:
Let's look at some MySQL TIME function examples and explore how to use the TIME function in MySQL.
For example:
mysql> SELECT TIME('2014-02-14 06:18:01.000001');
Output: '06:18:01.000001'
mysql> SELECT TIME('2014-02-17 18:20:19');
Output: '18:20:19'
mysql> SELECT TIME('10:35:05');
Output: '10:35:05'
mysql> SELECT TIME('The time is 10:35:05');
Output: '00:00:00'
mysql> SELECT TIME(NULL);
Output: NULL