SQL Reference

Quick Reference

The MySQL TIME_FORMAT() function formats a time by a specified format.

SELECT TIME_FORMAT('12:30:10', '%H %i %s');

Output

TIME_FORMAT('12:30:10', '%H %i %s')
12 30 10

Syntax

TIME_FORMAT(time, format)

Parametes

ParameterDescription
timeThe time to be modified (required)
formatThe format to use (required):

  • %f = Microseconds (000000 to 999999)

  • %H = Hour (00 to 23)

  • %h = Hour (00 to 12)

  • %I = Hour (00 to 12)

  • %i = Minutes (00 to 59)

  • %p = AM or PM

  • %r = Time in 12 hour AM or PM format (hh:mm:ss AM/PM)

  • %S = Seconds (00 to 59)

  • %s = Seconds (00 to 59)

  • %T = Time in 24 hour format (hh:mm:ss)


SQL Notes:

  • Any work being done to modify the structure of a database or delete tables or the the database itself should only be done after making a recent backup

We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.