MySQL TIME_DIFF expr1和expr2,以seconds.microseconds为单位

时间:2014-03-05 03:08:51

标签: mysql time seconds

我的表中有2个值,例如:

value1 = 08:30:11.600000 
value2 = 08:30:10.000000 

在数据类型为time(6)的字段中,应用TIME_DIFF导致:

00:00:01.600000 

结果表达的可能性如下1.60(second.microseconds)

或者如果值是

value1 = 08:31:11.600000 
value2 = 08:30:10.000000 
------------------------------
Result of **61.60**

我一直在测试

SELECT TIMEDIFF('08:30:11.600000','08:30:10.000000')

1 个答案:

答案 0 :(得分:0)

我想我理解你的要求,所以答案是:

mysql> SELECT CAST(TIMEDIFF('08:30:11.600000','08:30:10.000000')+0 AS DECIMAL(10,2));
+------------------------------------------------------------------------+
| CAST(TIMEDIFF('08:30:11.600000','08:30:10.000000')+0 AS DECIMAL(10,2)) |
+------------------------------------------------------------------------+
|                                                                   1.60 |
+------------------------------------------------------------------------+