使用DIFFTIME选择问题

时间:2012-12-20 03:50:58

标签: mysql select time nested datediff

我想知道两个日期之间的时差。 例如:

    SELECT TIMEDIFF('2012-12-19 22:00:00','2012-12-10 19:00:00');
+-------------------------------------------------------+
| TIMEDIFF('2012-12-19 22:00:00','2012-12-10 19:00:00') |
+-------------------------------------------------------+
| 219:00:00                                             |
+-------------------------------------------------------+
1 row in set (0.00 sec)

现在我想提取时间。

mysql> SELECT HOUR(SELECT TIMEDIFF('2012-12-19 22:00:00','2012-12-10 19:00:00'));
ERROR 1064 (42000): 

为什么不起作用?

2 个答案:

答案 0 :(得分:2)

尝试:

SELECT HOUR(TIMEDIFF('2012-12-19 22:00:00','2012-12-10 19:00:00'));

答案 1 :(得分:0)

这可以解决您的问题:

object FormBase: TFormBase
  Left = 0
  Top = 0
  Caption = 'FormBase'
  ClientHeight = 200
  ClientWidth = 329
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object ImageList1: TImageList
    Left = 32
    Top = 24
    Bitmap = {
      494C010101007800180010001000FFFFFFFFFF00FFFFFFFFFFFFFFFF424D3600
      snipped
      00000000000000000000000000000000}
  end
end