Name

TIME_FORMAT( )

Synopsis

TIME_FORMAT(time, format)

This function returns the time value of a time element provided and formats it according to formatting codes given as the second argument in parentheses. See the DATE_FORMAT( ) function for formatting codes but only those related to time values. This function will return NULL for other formatting codes.

SELECT TIME_FORMAT(appointment, '%r')
       AS 'Appt. Time' FROM appointments
WHERE client_id = '8373'
   AND appointment > SYSDATE( );
+-------------+
| Appt. Time  |
+-------------+
| 01:00:00 PM |
+-------------+

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.