The MySQL SEC_TO_TIME() function converts seconds into a formatted HH:MM:SS time string. It allows developers to perform deterministic data transformations directly within SQL queries.
TIMENULL if any required input argument evaluates to NULL.seconds-- Query demonstrating MySQL SEC_TO_TIME() usage in production queries
SELECT SEC_TO_TIME(3665) AS formatted_time;
| formatted_time |
|---|
| 01:01:05 |
IFNULL() or COALESCE() if your input columns allow NULL values.WHERE clauses disables B-tree index lookups (causing full table scans). Use generated columns with indexes when querying heavily.Write a SQL query using SEC_TO_TIME() to format or evaluate data retrieved from a database table.
Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.
Quick Access With