The TIME_FORMAT() function is used in a similar way to the DATE_FORMAT() function, but it can only be used to unload time values. If the TIME_FORMAT() function is used to unload a date value, MySQL returns a NULL value.
For example, when we pass the time format unit as a parameter to the MySQL TIME_FORMAT() function, MySQL only unloads the time as shown below -
mysql> Select TIME_FORMAT("2017-10-22 13:03:45", "%h %i %s %p")AS 'OFFLOADED TIME'; +----------------+ | OFFLOADED TIME | +----------------+ | 01 03 45 PM | +----------------+ 1 row in set (0.00 sec)
However, when we pass the date format unit as When parameters are passed to the MySQL TIME_FORMAT() function, MySQL will return NULL as shown below -
mysql> Select TIME_FORMAT("2017-10-22 13:03:45", "%Y %M %D") AS 'OFFLOADED DATE'; +----------------+ | OFFLOADED DATE | +----------------+ | NULL | +----------------+ 1 row in set (0.00 sec)
The above is the detailed content of How to unload time/date values in MySQL using TIME_FORMAT() function?. For more information, please follow other related articles on the PHP Chinese website!