Home > Database > Mysql Tutorial > MySQL中的DATE_ADD应用场景_MySQL

MySQL中的DATE_ADD应用场景_MySQL

WBOY
Release: 2016-05-30 17:10:58
Original
899 people have browsed it

MySQL中的DATE_ADD应用场景

 

/*当前时间加1毫秒*/
SELECT DATE_ADD(NOW(),INTERVAL 1 MICROSECOND);


/*当前时间减1毫秒*/
SELECT DATE_ADD(NOW(),INTERVAL -1 MICROSECOND);


/*当前时间加1秒*/
SELECT DATE_ADD(NOW(),INTERVAL 1 SECOND);


/*当前时间减1秒*/
SELECT DATE_ADD(NOW(),INTERVAL -1 SECOND);


/*当前时间加1分*/
SELECT DATE_ADD(NOW(),INTERVAL 1 MINUTE);


/*当前时间减1分*/
SELECT DATE_ADD(NOW(),INTERVAL -1 MINUTE);


/*当前时间加1小时*/
SELECT DATE_ADD(NOW(),INTERVAL 1 HOUR);


/*当前时间减1小时*/
SELECT DATE_ADD(NOW(),INTERVAL -1 HOUR);


/*当前日期加1天*/
SELECT DATE_ADD(NOW(),INTERVAL 1 DAY);


/*当前日期减1天*/
SELECT DATE_ADD(NOW(),INTERVAL -1 DAY);


/*当前日期加1月*/
SELECT DATE_ADD(NOW(),INTERVAL 1 MONTH);


/*当前日期减1月*/
SELECT DATE_ADD(NOW(),INTERVAL -1 MONTH);


/*当前日期加1季度*/
SELECT DATE_ADD(NOW(),INTERVAL 1 QUARTER);


/*当前日期减1季度*/
SELECT DATE_ADD(NOW(),INTERVAL -1 QUARTER);


/*当前日期加1年*/
SELECT DATE_ADD(NOW(),INTERVAL 1 YEAR);


/*当前日期减1年*/
SELECT DATE_ADD(NOW(),INTERVAL -1 YEAR);

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