mysql事件函数的应用

#############   取下个月的最后一天   ################################
mysql> select curdate()+interval 2 month - interval dayofmonth (curdate()) day;
+------------------------------------------------------------------+
| curdate()+interval 2 month - interval dayofmonth (curdate()) day |
+------------------------------------------------------------------+
| 2009-12-31                                                       |
+------------------------------------------------------------------+
1 row in set (0.00 sec)
##################   取下个月的第一天   #########################
mysql> select curdate()+interval 1 month - interval dayofmonth (curdate())-1 day;
+--------------------------------------------------------------------+
| curdate()+interval 1 month - interval dayofmonth (curdate())-1 day |
+--------------------------------------------------------------------+
| 2009-12-01                                                         |
+--------------------------------------------------------------------+
1 row in set (0.00 sec)
################  取当年的最后一天   ########################
mysql> select timestamp(concat(year(curdate()),'-12-31'));
+---------------------------------------------+
| timestamp(concat(year(curdate()),'-12-31')) |
+---------------------------------------------+
| 2009-12-31 00:00:00                         |
+---------------------------------------------+
1 row in set (0.01 sec)

mysql>

你可能感兴趣的:(mysql,数据库,函数,应用,休闲)