©SQL :: Manager
HomeProgram InformationTechnical detailsFree downloadDonate for a cup of coffee
myway SQL Manager for MySQL and MariaDB, Download on Uptodown
SQL functionMySQLMariaDB

The SEC_TO_TIME SQL Function in MySQL and MariaDB - Time from seconds

SEC_TO_TIMESyntax:SEC_TO_TIME(Seconds)
Return value:TIME
Function type:Date and Time function
Function Description

The SEC_TO_TIME() function calculates a time expression from the given number of "Seconds".

The "Seconds" argument can be a decimal number containing the microseconds.

If the decimal places for the microseconds of the "Seconds" argument are longer than 6, they are truncated.

If the value of the argument is invalid, a time value of 00:00:00.000000 is returned.

If the value of "Seconds" is NULL, the SEC_TO_TIME() function returns NULL.

SQL Examples for the SEC_TO_TIME function

 1
 2
 3
 4
 5
 6
 7
 8
 9
10

select sec_to_time(1000);
select sec_to_time(10000);
select sec_to_time(0.999);
select sec_to_time(0.99999994);
select sec_to_time(0.99999996);

select sec_to_time('xxx');
select sec_to_time(null);

sec_to_time(1000)
time(10)
00:16:40
sec_to_time(10000)
time(10)
02:46:40
sec_to_time(0.999)
time(14)
00:00:00.999
sec_to_time(0.99999994)
time(17)
00:00:00.999999
sec_to_time(0.99999996)
time(17)
00:00:00.999999
sec_to_time('xxx')
time(17)
00:00:00.000000
sec_to_time(null)
time(10)
NULL
The examples were created with the MyWAY SQL manager: Download

How to use the SEC_TO_TIME() function in MySQL and MariaDB databases

The SEC_TO_TIME() function in MySQL and MariaDB converts a number of seconds into a corresponding time value and returns a time value in the format "HH:MM:SS". The function can also be used in combination with other functions or calculations to handle more complex scenarios. When the number of seconds specified exceeds 86399, which is the maximum number of seconds in a day, the function wraps around to the next day. The SEC_TO_TIME() function also supports fractional seconds by passing a decimal value representing the number of fractional seconds. The function can be used in various SQL statements and calculations with time values.
RPAD_ORACLERTRIMSCHEMASEC_TO_TIMESECONDSESSION_USERSETVAL

Further MySQL und MariaDB SQL Date and Time functions

ADDDATEADDDATE(Date, [INTERVAL] Number [Unit])
More about ADDDATE Function

ADDTIMEADDTIME(Date, Expression)
More about ADDTIME Function

CONVERT_TZCONVERT_TZ(Date, From time zone, To time zone)
More about CONVERT_TZ Function

CURDATECURDATE()
More about CURDATE Function

CURTIMECURTIME([Precision])
More about CURTIME Function

CURRENT_DATECURRENT_DATE(-)
More about CURRENT_DATE Function

CURRENT_TIMECURRENT_TIME([Precision])
More about CURRENT_TIME Function

CURRENT_TIMESTAMPCURRENT_TIMESTAMP([Precision])
More about CURRENT_TIMESTAMP Function

DATEDATE(Date and Time)
More about DATE Function

DATE_ADDDATE_ADD(Date, INTERVAL Number Unit)
More about DATE_ADD Function

DATE_SUBDATE_SUB(Date, INTERVAL Number Unit)
More about DATE_SUB Function

FROM_DAYSFROM_DAYS(Number of days)
More about FROM_DAYS Function

FROM_UNIXTIMEFROM_UNIXTIME(Unix timestamp [, Format])
More about FROM_UNIXTIME Function

LOCALTIMELOCALTIME([Precision])
More about LOCALTIME Function

LOCALTIMESTAMPLOCALTIMESTAMP([Precision])
More about LOCALTIMESTAMP Function

MAKEDATEMAKEDATE(Year, Day of year)
More about MAKEDATE Function

MAKETIMEMAKETIME(Hours, Minutes, Seconds)
More about MAKETIME Function

NOWNOW([Precision])
More about NOW Function

SLEEPSLEEP(Seconds)
More about SLEEP Function

STR_TO_DATESTR_TO_DATE(String, Format)
More about STR_TO_DATE Function

SUBDATESUBDATE(Date, [INTERVAL] Number [Unit])
More about SUBDATE Function

SUBTIMESUBTIME(Date and Time, Deduction)
More about SUBTIME Function

SYSDATESYSDATE()
More about SYSDATE Function

TIMETIME(Date and Time)
More about TIME Function

TIMEDIFFTIMEDIFF(Date 1, Date 2)
More about TIMEDIFF Function

TIMESTAMPTIMESTAMP(Date [, Addition])
More about TIMESTAMP Function

TIMESTAMPADDTIMESTAMPADD(Unit, Number, Date)
More about TIMESTAMPADD Function

TIMESTAMPDIFFTIMESTAMPDIFF(Unit, Date 1, Date 2)
More about TIMESTAMPDIFF Function

UTC_DATEUTC_DATE()
More about UTC_DATE Function

UTC_TIMEUTC_TIME([Precision])
More about UTC_TIME Function

UTC_TIMESTAMPUTC_TIMESTAMP([Precision])
More about UTC_TIMESTAMP Function

DAYDAY(Date)
More about DAY Function

DAYOFMONTHDAYOFMONTH(Date)
More about DAYOFMONTH Function

DAYOFWEEKDAYOFWEEK(Date)
More about DAYOFWEEK Function

DAYOFYEARDAYOFYEAR(Date)
More about DAYOFYEAR Function

EXTRACTEXTRACT(Unit FROM Date)
More about EXTRACT Function

HOURHOUR(Date and Time)
More about HOUR Function

MICROSECONDMICROSECOND(Date and Time)
More about MICROSECOND Function

MINUTEMINUTE(Date and Time)
More about MINUTE Function

MONTHMONTH(Date)
More about MONTH Function

QUARTERQUARTER(Date)
More about QUARTER Function

SECONDSECOND(Date and Time)
More about SECOND Function

TIME_TO_SECTIME_TO_SEC(Time)
More about TIME_TO_SEC Function

TO_DAYSTO_DAYS(Date)
More about TO_DAYS Function

TO_SECONDSTO_SECONDS(Date and Time)
More about TO_SECONDS Function

UNIX_TIMESTAMPUNIX_TIMESTAMP([Date and Time])
More about UNIX_TIMESTAMP Function

WEEKWEEK(Date [, Mode])
More about WEEK Function

WEEKDAYWEEKDAY(Date)
More about WEEKDAY Function

WEEKOFYEARWEEKOFYEAR(Date)
More about WEEKOFYEAR Function

YEARYEAR(Date)
More about YEAR Function

YEARWEEKYEARWEEK(Date [, Mode])
More about YEARWEEK Function

DAYNAMEDAYNAME(Date)
More about DAYNAME Function

DATE_FORMATDATE_FORMAT(Date and Time, Format)
More about DATE_FORMAT Function

GET_FORMATGET_FORMAT(Type, Format)
More about GET_FORMAT Function

MONTHNAMEMONTHNAME(Date)
More about MONTHNAME Function

TIME_FORMATTIME_FORMAT(Time, Format)
More about TIME_FORMAT Function

Numeric functionsString functionsRegular ExpressionsDate and Time functions
Comparison functionsEncryption & CompressionConversion functionsNULL functions
Aggregate functionsWindow functionsJSON functionsGeometric functions
Sequence functionsInformation functionsDynamic ColumnsMiscellaneous functions
More information about the SEC_TO_TIME SQL function: mysql.com and mariadb.com and w3schools.com
Updated: 2023-09-17ImprintContactTerms & conditionsPrivacy & CookiesUpdatesSitemapFacebookLinkedinTwitterStatistics©2020-2024 Heino Cunze-Fischer