×

MySQL SEC_TO_TIME() function

In this context, we will learn how we can use the MySQL SEC_TO_TIME() function with proper syntax and good examples.

Introduction of MySQL SEC_TO_TIME() function

This function in MySQL is used to return a time value based on the specific value. Here, the returned time value will be in the format of HH:MM:SS. For example, if the specified second value is 63, this function will return "00:01:03".

Syntax of the MySQL SEC_TO_TIME() function

The syntax of the MySQL SEC_TO_TIME() function is given as follows:

SEC_TO_TIME(scnds)

Parameters or arguments used in MySQL SEC_TO_TIME() function:

There is only one parameter accepted by the SEC_TO_TIME() function in MySQL, which is given as follows:

SCNDS: It is the mentioned seconds value. This value may be both positive or negative in MySQL.

Returns:

It will return a time value based on the mentioned seconds value.

Application used for SEC_TO_TIME() function:

The SEC_TO_TIME() function can be used in the given below MySQL 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

Examples of MySQL SEC_TO_TIME() function:

Now we will look into some MySQL SEC_TO_TIME() function examples and will explore how we can use the SEC_TO_TIME function in MySQL.

Example 1:

In this example, we will get the time value of "00:00:30" from the specified parameter of 30 seconds value in MySQL.

SELECT SEC_TO_TIME(30);

Output:

00:00:30
1 row in set (0.00 sec)

Example 2:

In this example, we will get the time value of "00:01:30" from the specified parameter of 90 seconds value in MySQL.

SELECT SEC_TO_TIME(90);

Output:

00:01:30
1 row in set (0.00 sec)

Example 3:

In this example, we will get the time value of "01:00:35" from the specified parameter of 3635 seconds value.

SELECT SEC_TO_TIME(3635);

Output:

01:00:35
1 row in set (0.00 sec)

Application of MySQL SEC_TO_TIME() function:

This function is used to return a time value based on the specified seconds value.

Summary:

In the above context, we have learned how we can use the SEC_TO_TIME() function used to return a time value based on the specified seconds value.


Related Topics

MySQL FIND_IN_SET() function

In this context, we will learn how we can use the MySQL MOD() function with proper syntax and good examples. Introduction of MySQL MOD() function MySQL provides a built-in string function called...

4 minutes read.

MySQL Composite Index

Composite Index A composite index is an index that is used on multiple columns. MySQL management system manages multiple columns simultaneously. Therefore, the single index contains multiple columns in one query...

3 minutes read.

MySQL View

Introduction MySQL View is a virtual table to create a clone of the base table. The View does not contain its values or data. MySQL View creates to connect more than...

12 minutes read.

MySQL CROSS JOIN

MySQL CROSS JOIN combines all possibilities of the two or more tables and returns the result that contains every row from all contributing tables. It links several columns from the...

4 minutes read.

MySQL Clauses

MySQL Clauses MySQL system clauses are keywords or statements to handle information. It helps to operate a group of the data and apply it to require conditions. The clauses apply conditions...

16 minutes read.

MySQL POW() function

In this context, we will learn how we can use the MySQL POW() function with proper syntax and good examples. Introduction of MySQL POW() function This function in MySQL is used to...

2 minutes read.

MySQL MIN function

The MIN() function determines the minimum or lowest value of the data set. This function works on numerical data type values. If the table displays zero value, then the row...

4 minutes read.

MySQL Show index

This query helps to access and retrieve table information. This syntax displays the required index or all indexes of the table. It also displays the index type as per the...

3 minutes read.

MySQL IF statement

The IF statement shows the true condition of the control flow function. The first condition is necessary to fulfill the requirement. The other condition is optional in the "IF" statement....

3 minutes read.

MySQL Full text index

Full text index The full-text index in the table isused to search the full text of the data. This index assigns to the table using a "FULLTEXT" keyword. First, the table...

3 minutes read.

MySQL Vs MongoDB

What is MongoDB? MongoDB is a distributed, open-source, cross-platform document-based database which was created to scale and develop applications simply. It was created as a NoSQL database by MongoDB Inc. MongoDB gets...

6 minutes read.

MySQL DELETE JOIN

Sometimes join becomes complicated and unwanted. In such cases, we can delete the unwanted joins in the tables. You can delete inner join, left join, right join as per requirement....

3 minutes read.

MySQL INSTR() Function

In this context, we will learn how we can use the MySQL INSTR() function with proper syntax and good examples. Introduction of MySQL INSTR() function This function in MySQL returns the location...

4 minutes read.

MySQL Union

MySQL contains the same categories of data in a different table. Sometimes, you require multiple tables to collect data together. MySQL union is a function to combine two table's data...

5 minutes read.

MySQL Prefix index

Prefix index This index query creates an index column in the string or character column. MySQL system can create multiple indexes in the table. It will create in a table as...

3 minutes read.

MySQL DATE_FORMAT() function

In this context, we will learn how we can use the MySQL DATE_FORMAT() function with proper syntax and good examples. Introduction of MySQL DATE_FORMAT() function DATE_FORMAT() function in MySQL is used to...

3 minutes read.

MySQL MOD() function

In this context, we will learn how we can use the MySQL MOD() function with proper syntax and good examples. Introduction of MySQL MOD() function Basically, in MySQL, the MOD() function is...

3 minutes read.

MySQL LOG10() function

In this context, we will learn how we can use the MySQL LOG10() function with proper syntax and good examples. Introduction of MySQL LOG10() function To evaluate the natural logarithmic value of...

2 minutes read.

MySQL FORMAT() function

In this context, we will learn how we can use the MySQL FORMAT() function with proper syntax and good examples. Introduction of MySQL FORMAT() function This function in MySQL helps to format...

2 minutes read.

MySQL NOW() function

In this context, we will learn how we can use the MySQL NOW() function with proper syntax and good examples. Introduction of MySQL NOW() function Basically, in MySQL, this function is used...

2 minutes read.