tidb
tidb copied to clipboard
Behavior of str_to_date() is different from mysql
Please answer these questions before submitting your issue. Thanks!
-
What did you do? If possible, provide a recipe for reproducing the error.
select str_to_date('1,9,2017','%d,%m,%Y'); -
What did you expect to see?
MySQL
mysql> select str_to_date('01,09,2017','%d,%m,%Y');
+--------------------------------------+
| str_to_date('01,09,2017','%d,%m,%Y') |
+--------------------------------------+
| 2017-09-01 |
+--------------------------------------+
1 row in set (0.02 sec)
mysql> select str_to_date('1,9,2017','%d,%m,%Y');
+------------------------------------+
| str_to_date('1,9,2017','%d,%m,%Y') |
+------------------------------------+
| 2017-09-01 |
+------------------------------------+
1 row in set (0.00 sec)
- What did you see instead?
TiDB
MySQL [(none)]> select str_to_date('01,09,2017','%d,%m,%Y');
+--------------------------------------+
| str_to_date('01,09,2017','%d,%m,%Y') |
+--------------------------------------+
| 2017-09-01 00:00:00 |
+--------------------------------------+
1 row in set (0.00 sec)
MySQL [(none)]> select str_to_date('1,9,2017','%d,%m,%Y');
+------------------------------------+
| str_to_date('1,9,2017','%d,%m,%Y') |
+------------------------------------+
| NULL |
+------------------------------------+
1 row in set (0.00 sec)
MySQL [(none)]> select str_to_date('1,09,2017','%d,%m,%Y');
+-------------------------------------+
| str_to_date('1,09,2017','%d,%m,%Y') |
+-------------------------------------+
| NULL |
+-------------------------------------+
1 row in set (0.00 sec)
MySQL [(none)]> select str_to_date('01,9,2017','%d,%m,%Y');
+-------------------------------------+
| str_to_date('01,9,2017','%d,%m,%Y') |
+-------------------------------------+
| NULL |
+-------------------------------------+
1 row in set (0.00 sec)
- What version of TiDB are you using (
tidb-server -V)? Git Commit Hash: 365e4ab Git Commit Branch: master UTC Build Time: 2017-08-16 01:24:27
Related #3965