Seconds Since the Beginning of the Day : Introduction : Date Time Functions MySQL TUTORIALS


MySQL TUTORIALS » Date Time Functions » Introduction »

 

Seconds Since the Beginning of the Day


TIME_TO_SEC(time) returns the time in seconds (the number of seconds since the beginning of that day).

SEC_TO_TIME(seconds) does the opposite, converting the number of seconds from the beginning of the day into HH:MM:SS or HHMMSS format.

mysql>
mysql> select TIME_TO_SEC('01.00.00');
+-------------------------+
| TIME_TO_SEC('01.00.00') |
+-------------------------+
|                       |
+-------------------------+
row in set, warning (0.00 sec)

mysql>
mysql> SELECT TIME_TO_SEC(110);
+------------------+
| TIME_TO_SEC(110|
+------------------+
|               70 |
+------------------+
row in set (0.00 sec)

mysql>
mysql> SELECT SEC_TO_TIME(70);
+-----------------+
| SEC_TO_TIME(70|
+-----------------+
00:01:10        |
+-----------------+
row in set (0.00 sec)

mysql>
mysql> SELECT SEC_TO_TIME(1000)+0;
+---------------------+
| SEC_TO_TIME(1000)+|
+---------------------+
|         1640.000000 |
+---------------------+
row in set (0.02 sec)

mysql>



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

MySQL TUTORIALS

 Navioo Date Time Functions
» Introduction