当前位置:Gxlcms > mysql > mysql的一个日期有关问题,理解不了

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

时间:2021-07-01 10:21:17 帮助过:23人阅读

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)

注意红色部分,谁给解释一下?

人气教程排行