I\'m trying to understand what casting a value to the DATE type in MySQL does. Here are some things I have tried:
SELECT CAST(\'3\' AS DATE);
-- null
SELECT
Checking the source code of MySQL 5.6 CAST()
and CONVERT()
calls to the same internal function Item_date_typecast
, DATE()
calls to Item_date_typecast
too.
In conclusion there is no difference between DATE(expr)
function and the CAST(expr AS DATE)
.
Refs:
https://github.com/mysql/mysql-server/blob/5.6/sql/sql_yacc.yy
https://github.com/mysql/mysql-server/blob/5.6/sql/item_create.cc