时间:2021-07-01 10:21:17 帮助过:14人阅读
当前时间:
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2014-07-03 21:16:22 |
+---------------------+
1 row in set (0.00 sec)
下一个月:
mysql> select date_add(now(),interval 1 month);
+----------------------------------+
| date_add(now(),interval 1 month) |
+----------------------------------+
| 2014-08-03 21:16:28 |
+----------------------------------+
1 row in set (0.00 sec)
上一个月:
mysql> select date_add(now(),interval -1 month);
+-----------------------------------+
| date_add(now(),interval -1 month) |
+-----------------------------------+
| 2014-06-03 21:17:02 |
+-----------------------------------+
1 row in set (0.00 sec)
三个月前:
DATE_SUB(NOW(), INTERVAL 3 MONTH)
三个天前:
SELECT DATE_SUB(NOW(), INTERVAL 3 DAY)
mysql 几天前,几个月前
标签:mysql 日期