tidb icon indicating copy to clipboard operation
tidb copied to clipboard

Behavior of str_to_date() is different from mysql

Open tshqin opened this issue 9 years ago • 1 comments

Please answer these questions before submitting your issue. Thanks!

  1. What did you do? If possible, provide a recipe for reproducing the error. select str_to_date('1,9,2017','%d,%m,%Y');

  2. 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)
  1. 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)
  1. 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

tshqin avatar Aug 21 '17 17:08 tshqin

Related #3965

jackysp avatar Aug 22 '17 03:08 jackysp