DATETIME STR_TO_DATE(VARCHAR str, VARCHAR format)
通过format指定的方式将str转化为DATE类型,如果转化结果不对返回NULL
支持的format格式与 date_format 一致
MySQL > select str_to_date('2014-12-21 12:34:56', '%Y-%m-%d %H:%i:%s');
+---------------------------------------------------------+
| str_to_date('2014-12-21 12:34:56', '%Y-%m-%d %H:%i:%s') |
+---------------------------------------------------------+
| 2014-12-21 12:34:56 |
+---------------------------------------------------------+
MySQL > select str_to_date('2014-12-21 12:34:56', '%Y-%m-%d %H:%i:%s');
+--------------------------------------------------------------+
| str_to_date('2014-12-21 12:34%3A56', '%Y-%m-%d %H:%i:%s') |
+--------------------------------------------------------------+
| 2014-12-21 12:34:56 |
+--------------------------------------------------------------+
MySQL > select str_to_date('200442 Monday', '%X%V %W');
+-----------------------------------------+
| str_to_date('200442 Monday', '%X%V %W') |
+-----------------------------------------+
| 2004-10-18 |
+-----------------------------------------+
STR_TO_DATE,STR,TO,DATE