Home >Database >Mysql Tutorial >How to convert hours, minutes and seconds into seconds in mysql
In mysql, you can use the TIME_TO_SEC() function to convert hours, minutes, and seconds into seconds. The syntax is "TIME_TO_SEC("hour:minute:second")". The TIME_TO_SEC() function accepts a time value as a parameter and converts the parameter into seconds. The conversion formula is "(hour × 3600) (minute × 60) second".
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
In mysql, you can use the TIME_TO_SEC() function to convert hours, minutes and seconds into seconds.
MySQL TIME_TO_SEC() function will accept a time value as a parameter, convert the parameter into seconds, and then return. The conversion formula is "(hour × 3600) (minute × 60) second".
Syntax:
TIME_TO_SEC(time)
Parameters | Description |
---|---|
time | Required. Time value |
Example 1:
mysql> SELECT TIME_TO_SEC('15:15:15');
It can be seen from the execution results that according to the calculation formula " 15×3600 15×60 15” gives the result of seconds 54915.
Example 2:
mysql> SELECT TIME_TO_SEC('22:23:00');
It can be seen from the execution result that according to the calculation formula "22×3600 23×60", the result number of seconds is 80580.
[Related recommendations: mysql video tutorial]
The above is the detailed content of How to convert hours, minutes and seconds into seconds in mysql. For more information, please follow other related articles on the PHP Chinese website!