Mega Code Archive

 
Categories / MySQL Tutorial / Date Time Functions
 

SEC_TO_TIME(seconds) returns the seconds argument, converted to hours, minutes, and seconds

The returning value is in the format of 'HH:MM:SS' or HHMMSS format, depending on whether the function is used in a string or numeric context. mysql> mysql> SELECT SEC_TO_TIME(1378); +-------------------+ | SEC_TO_TIME(1378) | +-------------------+ | 00:22:58          | +-------------------+ 1 row in set (0.00 sec) mysql> mysql> SELECT SEC_TO_TIME(2478) + 0; +-----------------------+ | SEC_TO_TIME(2478) + 0 | +-----------------------+ |           4118.000000 | +-----------------------+ 1 row in set (0.00 sec) mysql>