MySQL: SEC_TO_TIME Function with Examples

MySQL: SEC_TO_TIME Function with Examples

Here, we will demonstrate how to works the sec_to_time() function of MySQL and how to use this function with various examples.

MySQL SEC_TO_TIME() Function

The Mysql SEC_TO_TIME () function is used to create time values ​​based on a given second.

Note: Basically, you provide a number of seconds as an argument, and it will change it to a time value.


The syntax of sec_to_time() function is:


Hereseconds is the number of seconds you want to be converted to a time value.

List of Examples –

Let’s take at some MySQL SEC_TO_TIME function examples and find out how to use the SEC_TO_TIME function.


Let’s take a simple and basic example of this function is:



| SEC_TO_TIME(100) |
| 00:01:40         |


Here, We take an example with the large value:



| SEC_TO_TIME(7555) |
|  02:05:55         |


Take an example of using the SEC_TO_TIME () function in a numerical context.

    SEC_TO_TIME(4555) + 0;


| SEC_TO_TIME(4555) | SEC_TO_TIME(4555) + 0 |
| 01:15:55          |                 115555|


Here, you have learned how to use SEC_TO_TIME() function with various examples.

You may like

  1. MySQL CURRENT TIMESTAMP Function Examples
  2. MySQL CURRENT TIME Function Examples
  3. ADDTIME() Function Examples – MySQL
  4. MINUTE() Function Examples – MySQL
  5. HOUR() Function Examples – MySQL
  6. SECOND() Function Examples – MySQL
  7. MICROSECOND() Function Examples – MySQL
  8. TO_DAYS() Function Examples – MySQL
  9. Get month name from date in mysql
  10. mysql get first day of the current month
  11. mysql last day of previous month
  12. Get month number from month name in mysql
  13. mysql get day of week number from date
  14. Mysql Get Data Of Current Date, Week, Month, YEAR
  15. Query For Get Data Of Last Day, Week, Month, YEAR – Mysql

If you have any questions or thoughts to share, use the comment form below to reach us.


My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Javascript, JQuery, Laravel, Livewire, Codeigniter, Vue JS, Angular JS, React Js, WordPress, and Bootstrap from a starting stage. As well as demo example.