mysql 存储过程时间月份减法
declare startTime VARCHAR(19) default '2014-00-00 00:00:00';
declare tempTime VARCHAR(19) default NOW();
declare endTime VARCHAR(19) default DATE_SUB(tempTime,INTERVAL '3' MONTH); -- 后退三个月时间
DECLARE MONTHSTR VARCHAR(7) default SUBSTR(endTime,1,7);
set endTime=CONCAT(MONTHSTR,'-00 00:00:00');
SELECT startTime as startTime,endTime AS endTime;
declare tempTime VARCHAR(19) default NOW();
declare endTime VARCHAR(19) default DATE_SUB(tempTime,INTERVAL '3' MONTH); -- 后退三个月时间
DECLARE MONTHSTR VARCHAR(7) default SUBSTR(endTime,1,7);
set endTime=CONCAT(MONTHSTR,'-00 00:00:00');
SELECT startTime as startTime,endTime AS endTime;
posted on 2017-05-10 12:24 cynchanpin 阅读(1552) 评论(0) 编辑 收藏 举报