Home > Database > Mysql Tutorial > mysql的一个日期有关问题,理解不了

mysql的一个日期有关问题,理解不了

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 16:24:37
Original
1070 people have browsed it

mysql的一个日期问题,理解不了 mysql select date_sub( '2014-03-04' ,interval dayofmonth(curdate())-1 day); +-------------------------------------------------------------+ | date_sub('2014-03-04',interval dayofmonth(curdate())-1 day) | +-----

mysql的一个日期问题,理解不了
mysql> select date_sub('2014-03-04',interval dayofmonth(curdate())-1 day);
+-------------------------------------------------------------+
| date_sub('2014-03-04',interval dayofmonth(curdate())-1 day) |
+-------------------------------------------------------------+
| 2014-02-14                                                  |
+-------------------------------------------------------------+
1 row in set (0.00 sec)

把这个日期插入到表中:
mysql> select * from t_date_3;
+---------------------+------+
| t_create            | val  |
+---------------------+------+
| 2014-03-17 14:08:13 |    6 |
| 2014-03-17 14:08:31 |   11 |
| 2014-03-04 00:00:00 | NULL |
+---------------------+------+
3 rows in set (0.00 sec)

然后:
mysql> select date_sub(t_create,interval dayofmonth(t_create)-1 day) from t_date
_3;
+--------------------------------------------------------+
| date_sub(t_create,interval dayofmonth(t_create)-1 day) |
+--------------------------------------------------------+
| 2014-03-01 14:08:13                                    |
| 2014-03-01 14:08:31                                    |
| 2014-03-01 00:00:00                                    |
+--------------------------------------------------------+
3 rows in set (0.00 sec)

注意红色部分,谁给解释一下?
Related labels:
source:php.cn
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
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template