Home > Database > Mysql Tutorial > body text

Why can't we use MySQL DATE data type with time values?

WBOY
Release: 2023-08-25 15:57:14
forward
1295 people have browsed it

为什么我们不能将 MySQL DATE 数据类型与时间值一起使用?

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!