`TIMESTAMPDIFF` should return null for invalid datetimes
- Dominant language
- Go
- Stars
- 24.4k
- Forks
- 873
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 108
Description
Dolt currently errors out for invalid datetimes whereas MySQL returns null with a warning
Dolt
```
tmp/main*> select timestampdiff(microsecond, "2020-12-12","hi");
Incorrect datetime value: 'hi'
tmp/main*> select timestampdiff(microsecond, "2020-12-12", 1);
Incorrect datetime value: '1'
```
MySQL
```
mysql> select timestampdiff(microsecond, "2020-12-12","hi");
+-----------------------------------------------+
| timestampdiff(microsecond, "2020-12-12","hi") |
+-----------------------------------------------+
| NULL |
+-----------------------------------------------+
1 row in set, 1 warning (0.00 sec)
mysql> show warnings;
+---------+------+--------------------------------+
| Level | Code | Message |
+---------+------+--------------------------------+
| Warning | 1292 | Incorrect datetime value: 'hi' |
+---------+------+--------------------------------+
1 row in set (0.00 sec)
mysql> select timestampdiff(microsecond, "2020-12-12", 1);
+---------------------------------------------+
| timestampdiff(microsecond, "2020-12-12", 1) |
+---------------------------------------------+
| NULL |
+---------------------------------------------+
1 row in set, 1 warning (0.00 sec)
mysql> show warnings ;
+---------+------+-------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------+
| Warning | 1292 | Incorrect datetime value: '1' |
+---------+------+-------------------------------+
1 row in set (0.00 sec)
mysql> select timestampdiff(microsecond, "hi", 1);
+-------------------------------------+
| timestampdiff(microsecond, "hi", 1) |
+-------------------------------------+
| NULL |
+-------------------------------------+
1 row in set, 1 warning (0.00 sec)
mysql> show warnings;
+---------+------+--------------------------------+
| Level | Code | Message |
+---------+------+--------------------------------+
| Warning | 1292 | Incorrect datetime value: 'hi' |
+---------+------+--------------------------------+
1 row in set (0.00 sec)
```
note that when there are 2 invalid values, a warning only shows for the first one
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.