DELIMITER //
CREATE FUNCTION SEC_TO_TIMEB (in_seconds bigint) RETURNS VARCHAR(15)
BEGIN
DECLARE hours VARCHAR(9) DEFAULT '0';;
DECLARE minutes CHAR(2) DEFAULT '0';;
DECLARE seconds CHAR(2) DEFAULT '0';;
SET hours := FLOOR(in_seconds / 3600);
SET hours := IF(hours < 10,CONCAT('0',hours),hours);
SET minutes := FLOOR(MOD(in_seconds,3600) / 60);
SET minutes := IF(minutes < 10,CONCAT('0',minutes),minutes);
SET seconds := MOD(MOD(in_seconds,3600),60);
SET seconds := IF(seconds < 10,CONCAT('0',seconds),seconds);
RETURN CONCAT(hours,':',minutes,':',seconds);
END //
DELIMITER ;