I have the following create function block for SQL
/**
* tos_get_duration.sql
*
* Given time unit in seconds, it converts to more readable format
*
* Eg. SELECT TOS_GET_DURATION(72) => 00d 0:1:12
*/
DROP FUNCTION IF EXISTS TOS_GET_DURATION;
DELIMITER $$
CREATE FUNCTION TOS_GET_DURATION(seconds INT)
RETURNS VARCHAR(16)
BEGIN
RETURN CONCAT(LPAD(FLOOR(HOUR(SEC_TO_TIME(seconds)) / 24), 2, 0), ' days ',TIME_FORMAT(SEC_TO_TIME(seconds % (24 * 3600)), '%H:%i:%s'));
END;
$$
DELIMITER;
it is taken from timeonsite analytics reporting query page.
It used to be working well in MySql but I recently switched to MariaDB and tried executed this function; this function basically converts seconds to more human readable string format. I get following error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'DELIMITER' at line 1
Server version: 10.5.16-MariaDB - MariaDB Server
Kindly help me find the issue and suggest me common "create function" format I can use in both MySql and MariaDB databases.
