I tested this:
SET @t = '19:00:00';
SELECT CONCAT_WS(', ',
CONCAT(NULLIF(TIME_FORMAT(@t, '%H'), '00'), ' hours'),
CONCAT(NULLIF(TIME_FORMAT(@t, '%i'), '00'), ' minutes'),
CONCAT(NULLIF(TIME_FORMAT(@t, '%s'), '00'), ' seconds')) AS time_expr;
Conclusion:
+-----------+
| time_expr |
+-----------+
| 19 hours |
+-----------+
When I set the time to something else:
SET @t = '19:00:05';
Conclusion:
+----------------------+
| time_expr |
+----------------------+
| 19 hours, 05 seconds |
+----------------------+
It even processes zero hours:
SET @t = '00:43:00';
Conclusion:
+------------+
| time_expr |
+------------+
| 43 minutes |
+------------+
source
share