1. addtime() Add the specified number of seconds to the date select addtime(now(),1); -- add 1 second 2. adddate() There are two ways to use it. If you fill in a number directly in the second parameter, it will add the specified number of days to the date. If you fill in interval, it will add the specified interval time to the date. select adddate(now(),1); -- add 1 dayselect adddate(now(), interval 1 day); -- add 1 dayselect adddate(now(), interval 1 hour); -- add 1 hourselect adddate(now(), interval 1 minute); -- add 1 minuteselect adddate(now(), interval 1 second); -- add 1 secondselect adddate(now(), interval 1 microsecond); -- add 1 millisecondselect adddate(now(), interval 1 week); -- add 1 weekselect adddate(now(), interval 1 month); -- add 1 monthselect adddate(now(), interval 1 quarter); -- add 1 quarterselect adddate(now(), interval 1 year); -- add 1 year 3. date_add() Add a time interval to the date. This can only use the interval time as a parameter. The usage is the same as adddate() select date_add(now(), interval 1 day); -- add 1 dayselect date_add(now(), interval 1 hour); -- add 1 hourselect date_add(now(), interval 1 minute); -- add 1 minuteselect date_add(now(), interval 1 second); -- add 1 secondselect date_add(now(), interval 1 microsecond); -- add 1 millisecondselect date_add(now(), interval 1 week); -- add 1 weekselect date_add(now(), interval 1 month); -- add 1 monthselect date_add(now(), interval 1 quarter); -- add 1 quarterselect date_add(now(), interval 1 year); -- add 1 year 4. subtime() Subtract the specified number of seconds from the date select subtime(now(), 1); -- minus 1 second 5. subdate() The usage is the same as adddate() function. There are two usages. If you fill in a number directly in the second parameter, it will subtract the specified number of days from the date. If you fill in interval, it will subtract the specified interval time from the date. select subdate(now(),1); -- subtract 1 dayselect subdate(now(), interval 1 day); -- subtract 1 dayselect subdate(now(), interval 1 hour); -- subtract 1 hourselect subdate(now(), interval 1 minute); -- subtract 1 minuteselect subdate(now(), interval 1 second); -- subtract 1 secondselect subdate(now(), interval 1 microsecond); -- subtract 1 millisecondselect subdate(now(), interval 1 week); -- subtract 1 weekselect subdate(now(), interval 1 month); -- subtract 1 monthselect subdate(now(), interval 1 quarter); -- subtract 1 quarterselect subdate(now(), interval 1 year); -- subtract 1 year 6. date_sub() Same as date_add() function, subtract a time interval from the date. This function can only use interval time as a parameter. select date_sub(now(), interval 1 day); -- subtract 1 dayselect date_sub(now(), interval 1 hour); -- subtract 1 hourselect date_sub(now(), interval 1 minute); -- subtract 1 minuteselect date_sub(now(), interval 1 second); -- subtract 1 secondselect date_sub(now(), interval 1 microsecond); -- subtract 1 millisecondselect date_sub(now(), interval 1 week); -- subtract 1 weekselect date_sub(now(), interval 1 month); -- subtract 1 monthselect date_sub(now(), interval 1 quarter); -- subtract 1 quarterselect date_sub(now(), interval 1 year); -- subtract 1 year This is the end of this article about the detailed explanation of MySQL date addition and subtraction functions. For more relevant MySQL date addition and subtraction function summary content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Vue simulates the shopping cart settlement function
>>: Linux performance monitoring tool nmon installation and usage tutorial analysis
Table of contents introduce Usage scenarios Sourc...
Recently, when I was learning docker, I found tha...
Data migration needs to be imported from MySQL to...
First, you can open Moments and observe several l...
Two major categories of indexes Storage engine us...
Table of contents Preface: 1.Brief introduction t...
Concurrency Functions time for i in `grep server ...
The commands pulled by docker are stored in the /...
1. Idea It only took 6 seconds to insert 1,000,00...
grammar: background-image: conic-gradient(from an...
I have been studying how to get https. Recently I...
Preface These principles are summarized from actu...
The Swap partition of the Linux system, that is, ...
Table of contents Nginx load balancing configurat...
Table of contents event Page Loading Event Delega...