MySQL TIME() Function

In MySQL, the TIME() function extracts the time part from a time or datetime and return it.

TIME() Syntax

Here is the syntax of MySQL TIME() function:

TIME(expr)

Parameters

expr
Required. A date or datetime expression.

Return value

MySQL the TIME() function returns the time part of the specified time or datetime.

If expr is not a valid time or datetime, the TIME() function will return NULL.

If the argument is NULL, the TIME() function will return NULL.

TIME() Examples

Here are some examples of the TIME() function.

SELECT
    TIME('10:10:10'),
    TIME('2022-02-28 10:10:10'),
    TIME('10:10:10.001112'),
    TIME('2022-02-28 10:10:10.001112'),
    TIME(NOW()),
    TIME('Not A Date'),
    TIME(NULL)\G
                  TIME('10:10:10'): 10:10:10
       TIME('2022-02-28 10:10:10'): 10:10:10
           TIME('10:10:10.001112'): 10:10:10.001112
TIME('2022-02-28 10:10:10.001112'): 10:10:10.001112
                       TIME(NOW()): 09:12:55
                TIME('Not A Date'): NULL
                        TIME(NULL): NULL