MySQL CAST as DATE

前端 未结 1 432
心在旅途
心在旅途 2020-12-09 15:17

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          


        
相关标签:
1条回答
  • 2020-12-09 15:28

    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

    0 讨论(0)
提交回复
热议问题