Home > Database > Mysql Tutorial > body text

mysql存储过程时间月份减法_MySQL

WBOY
Release: 2016-06-01 12:59:05
Original
1095 people have browsed it

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;

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!