TIME_FORMAT(SEC_TO_TIME(task_records.time_spent),'%Hh %im')
Dokumentace je váš přítel:
Podle komentáře:
DROP FUNCTION IF EXISTS GET_HOUR_MINUTES;
CREATE FUNCTION GET_HOUR_MINUTES(seconds INT)
RETURNS VARCHAR(16)
BEGIN
DECLARE result VARCHAR(16);
IF seconds >= 3600 THEN SET result = TIME_FORMAT(SEC_TO_TIME(seconds),'%kh %lm');
ELSE SET result = TIME_FORMAT(SEC_TO_TIME(seconds),'%lm');
RETURN result;
END
DELIMETER ;
Použití:
SELECT GET_HOUR_MINUTES(task_records.time_spent) FROM table