MySQL: TIME Function

  • Post author:
  • Post category:MySQL
  • Post comments:1 Comment
MySQL TIME Function

In this guide, we will explain how to use the MySQL TIME function with syntax and examples.

Description

The MySQL TIME function extracts the time value from a time/datetime expression.

Syntax

The syntax for the TIME function inis:

TIME( expression )

Parameters or Arguments

expression

The time or datetime value from which the time should be extracted.

Note

  • If expression is not a time or a datetime value, the TIME function will return ’00:00:00′.
  • If expression is NULL, the TIME function will return NULL.
  • See also the CAST function.

Applies To

The TIME function can be used in the following versions :

  • MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1.1

Example

Let’s look at some TIME function examples and explore how to use the TIME function.

For example:

mysql> SELECT TIME('2014-02-14 06:18:01.000001');
Result: '06:18:01.000001'

mysql> SELECT TIME('2014-02-17 18:20:19');
Result: '18:20:19'

mysql> SELECT TIME('10:35:05');
Result: '10:35:05'

mysql> SELECT TIME('The time is 10:35:05');
Result: '00:00:00'

mysql> SELECT TIME(NULL);
Result: NULL

Next Topic : Click Here

This Post Has One Comment

Leave a Reply