MariaDB Tutorial MariaDB Advanced MariaDB Database Account Management MariaDB References

MariaDB SEC_TO_TIME() Function



The MariaDB SEC_TO_TIME() function returns a time value (in format HH:MM:SS) based on the specified seconds. A time value (returned value) can range from '-838:59:59' to '838:59:59'.

Syntax

SEC_TO_TIME(seconds)

Parameters

seconds Required. Specify the number of seconds. Both positive or negative values are allowed.

Return Value

Returns the time value (in format HH:MM:SS) based on the specified seconds.

Example 1:

The example below shows the usage of SEC_TO_TIME() function.

SELECT SEC_TO_TIME(50);
Result: '00:00:50'

SELECT SEC_TO_TIME(500);
Result: '00:08:20'

SELECT SEC_TO_TIME(10000);
Result: '02:46:40'

SELECT SEC_TO_TIME(423456);
Result: '117:37:36'

SELECT SEC_TO_TIME(-423456);
Result: '-117:37:36'

Example 2:

Consider a database table called Sample with the following records:

DataSeconds
Data 125789
Data 235909
Data 330144
Data 424003
Data 544321

The statement given below can be used to get the time value by converting the records of column Seconds.

SELECT *, SEC_TO_TIME(Seconds) AS SEC_TO_TIME_Value FROM Sample;

This will produce the result as shown below:

DataSecondsSEC_TO_TIME_Value
Data 12578907:09:49
Data 23590909:58:29
Data 33014408:22:24
Data 42400306:40:03
Data 54432112:18:41

❮ MariaDB Functions