MySQL: TIME_TO_SEC Function

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

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

Description

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

Syntax

The syntax for the TIME_TO_SEC function is:

TIME_TO_SEC( time )

Parameters or Arguments

time

The time value to convert to numeric seconds.

Note

  • See also the SEC_TO_TIME function.

Applies To

The TIME_TO_SEC 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 TIME_TO_SEC function examples and explore how to use the TIME_TO_SEC function.

For example:

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

mysql> SELECT TIME_TO_SEC('00:00:01.999999');
Result: 1

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

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

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

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

Next Topic : Click Here

This Post Has One Comment

Leave a Reply