Support TIME type and timediff function (#1505)

This commit is contained in:
HangyuanLiu
2019-07-23 13:42:40 +08:00
committed by ZHAO Chun
parent 221cd2e103
commit 4aedaea84e
37 changed files with 318 additions and 20 deletions

View File

@ -2,7 +2,7 @@
## Syntax
`DATETIME DATEDIFF(expr1,expr2)`
`DATETIME DATEDIFF(DATETIME expr1,DATETIME expr2)`
## Description
@ -28,4 +28,4 @@ mysql> select datediff(CAST('2010-11-30 23:59:59' AS DATETIME), CAST('2010-12-31
+-----------------------------------------------------------------------------------+
| -31 |
+-----------------------------------------------------------------------------------+
```
```

View File

@ -0,0 +1,46 @@
# timediff
## Syntax
`TIME TIMEDIFF(DATETIME expr1, DATETIME expr2)`
## Description
TIMEDIFF��������DATETIME֮���IJ�ֵ
TIMEDIFF�������ر�ʾΪʱ��ֵ��expr1 - expr2�Ľ���������ֵΪTIME����
�������������ڴ�-838:59:59��838:59:59֮����TIMEֵ��Χ��
## Examples
```
mysql> SELECT TIMEDIFF(now(),utc_timestamp());
+----------------------------------+
| timediff(now(), utc_timestamp()) |
+----------------------------------+
| 08:00:00 |
+----------------------------------+
mysql> SELECT TIMEDIFF('2019-07-11 16:59:30','2019-07-11 16:59:21');
+--------------------------------------------------------+
| timediff('2019-07-11 16:59:30', '2019-07-11 16:59:21') |
+--------------------------------------------------------+
| 00:00:09 |
+--------------------------------------------------------+
mysql> SELECT TIMEDIFF('2019-01-01 00:00:00', '2009-01-01 00:00:00');
+--------------------------------------------------------+
| timediff('2019-01-01 00:00:00', '2009-01-01 00:00:00') |
+--------------------------------------------------------+
| 838:59:59 |
+--------------------------------------------------------+
mysql> SELECT TIMEDIFF('2019-01-01 00:00:00', NULL);
+---------------------------------------+
| timediff('2019-01-01 00:00:00', NULL) |
+---------------------------------------+
| NULL |
+---------------------------------------+
```