MySQL: SEC_TO_TIME Function

  • Post author:
  • Post category:MySQL
  • Post comments:1 Comment
MySQL SEC_TO_TIME Function

In this guide, we will explain how to use the MySQL SEC_TO_TIME function with syntax and examples.

Description

The MySQL SEC_TO_TIME function converts numeric seconds into a time value.

Syntax

The syntax for the SEC_TO_TIME function is:

SEC_TO_TIME( seconds )

Parameters or Arguments

seconds

A numeric value representing the number of seconds. This value can be positive or negative.

Note

  • Time values range from ‘-838:59:59’ to ‘838:59:59’.
  • The SEC_TO_TIME function will format the result as “HH:MM:SS”.
  • See also the TIME_TO_SEC function.

Applies To

The SEC_TO_TIME function can be used in the following versions :

  • MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23

Example

Let’s look at some SEC_TO_TIME function examples and explore how to use the SEC_TO_TIME function.

For example:

mysql> SELECT SEC_TO_TIME(1);
Result: '00:00:01'

mysql> SELECT SEC_TO_TIME(2);
Result: '00:00:02'

mysql> SELECT SEC_TO_TIME(8001);
Result: '02:13:21'

mysql> SELECT SEC_TO_TIME(34562);
Result: '09:36:02'

mysql> SELECT SEC_TO_TIME(-7005);
Result: '-01:56:45'

Next Topic : Click Here

This Post Has One Comment

Leave a Reply