MySQL: TIME_FORMAT Function

0
560

Let’s look at some MySQL TIME_FORMAT function examples and explore how to use the TIME_FORMAT function in MySQL.

For example:

mysql> SELECT TIME_FORMAT('15:02:28', '%H %i %s');
Result: '15 02 28'

mysql> SELECT TIME_FORMAT('15:02:28', '%h:%i:%s %p');
Result: '03:02:28 PM'

mysql> SELECT TIME_FORMAT('15:02:28', '%h:%i%p');
Result: '03:02PM'

mysql> SELECT TIME_FORMAT('17:42:03.000001', '%r');
Result: '05:42:03 PM'

mysql> SELECT TIME_FORMAT('17:42:03.000001', '%T');
Result: '17:42:03'

mysql> SELECT TIME_FORMAT('07:42:03.000001', '%f');
Result: '000001'

LEAVE A REPLY

Please enter your comment!
Please enter your name here