MYSQL TIME FUNCTIONS
MYSQL TIME FUNCTIONS is a SQL function in the MySQL Specific category. MySQL: TIME_TO_SEC converts time to seconds. SEC_TO_TIME converts seconds back to TIME. The syntax is TIME_TO_SEC(time) / SEC_TO_TIME(seconds). It accepts time. It returns converted time value. A typical example: SELECT TIME_TO_SEC('01:30:00'); -- 5400 (seconds) SELECT SEC_TO_TIME(5400); -- 01:30:00 -- Calculate total time: SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(overtime))) FROM timesheets WHERE employee_id = 1; A close relative is AUTO_INCREMENT, which mySQL auto-generates sequential integer values for this column. Commonly used with PRIMARY KEY. A close relative is ENGINE, which specifies the MySQL storage engine. InnoDB (default) supports transactions and foreign keys. MyISAM is faster for read-heavy. A close relative is LAST_INSERT_ID(), which returns the AUTO_INCREMENT value generated by the most recent INSERT in the current connection. More about this category: MySQL-specific features — AUTO_INCREMENT, ENGINE, SHOW TABLES, LIMIT. Related MySQL Specific entries: AUTO_INCREMENT, ENGINE, LAST_INSERT_ID(), ON DUPLICATE KEY UPDATE, LOAD DATA INFILE, LOCK TABLES / UNLOCK TABLES, FIND_IN_SET(), CHARACTER SET / COLLATION.