TIME_FORMAT Function

Description

The TIME_FORMAT function converts the value of strings with TIME format ('HH-MI-SS) or that of date/time data type (DATE, TIMESTAMP, DATETIME) to specified date/time format and then return the value with the VARCHAR data type.

Syntax

TIME_FORMAT(time, format)

Example

SELECT TIME_FORMAT('22:23:00', '%H %i %s');

 time_format('22:23:00', '%H %i %s')

======================

  '22 23 00'

 

SELECT TIME_FORMAT('23:59:00', '%H %h %i %s %f');

 time_format('23:59:00', '%H %h %i %s %f')

======================

  '23 11 59 00 000'

 

SELECT SYSTIME, TIME_FORMAT(SYSTIME, '%T');

 SYS_TIME     time_format( SYS_TIME , '%T')

===================================

  08:46:53 PM  '20:46:53'