Forcing MySQL to Treat Strings as Temporal Values : TIME_TO_SEC « Date Time « SQL / MySQL






Forcing MySQL to Treat Strings as Temporal Values

      
mysql>
mysql> SELECT SEC_TO_TIME(TIME_TO_SEC('12:30:45'))+0;
+----------------------------------------+
| SEC_TO_TIME(TIME_TO_SEC('12:30:45'))+0 |
+----------------------------------------+
|                          123045.000000 |
+----------------------------------------+
1 row in set (0.00 sec)

mysql>

   
    
    
    
    
    
  








Related examples in the same category

1.Breaking Down Time Intervals into Components
2.If you pass TIME_TO_SEC( ) a date-and-time value, it extracts the time part and discards the date.
3.TIME_TO_SEC( ) converts a TIME value to the equivalent number of seconds
4.TIME_TO_SEC(): strips off the date part and returns the time part as the corresponding number of seconds:
5.To compute the total elapsed time, use TIME_TO_SEC( ) to convert the values to seconds before summing them.
6.Using TIME_TO_SEC( ) to strip off the date part of the t_create values
7.Transform the time differences into seconds using TIME_TO_SEC, add them, and then convert them back
8.To express time values as minutes, hours, or days, perform the appropriate divisions: