MySQL Time() Function

MySQL time() function; In this tutorial, i am going to show you MySQL time() functions with the help of examples.

MySQL time() Function

The TIME() function extracts the time part from a given time/datetime.

Syntax of MySQL time() Function

TIME(DateTime/Time)

Here, DateTime/Time:- It is a required.

Example 1 – MySQL time() Function

Let’s take the first example using MySQL time() function; as follows:

SELECT TIME("2020-01-04 10:21:15");

The output of the above query is the following:

 10:21:15

Example 2 – MySQL time() Function with Null Parameter

Let’s take an example using MySQL time() functin with NULL value; as follows:

SELECT TIME(NULL);

The output of the above query is the following:

TIME(NULL)

Example 3 – MySQL time() Function with Fractional Seconds

To select/extract time fractional time part of the given DateTime value; as follows:

SELECT TIME('2020-01-04 11:14:12.123456');

The output of the above query is the following:

11:14:12.123456

Conclusion

MySQL time() function; Through this tutorial, you have learned MySQL time() functions with the help of examples.

Leave a Comment