The default format of the MySQL DATE data type is "YYYY-MM-DD". In this format, time values cannot be stored. Therefore, we can say that we cannot use DATE data type with time values.
As we can see in the example below, MySQL only returns date values even when using time with date.
mysql> select DATE("2017-09-25 09:34:21"); +-----------------------------------+ | DATE("2017-09-25 09:34:21") | +-----------------------------------+ | 2017-09-25 | +-----------------------------------+ 1 row in set (0.04 sec)
However, in DATETIME and TIMESTAMP date data types, we can use time to date.
The above is the detailed content of Why can't we use MySQL DATE data type with time values?. For more information, please follow other related articles on the PHP Chinese website!