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
Preface Only Innodb and MyISAM storage engines ca...
Table of contents 1. Commonjs exports and require...
/******************** * Virtual File System VFS *...
Record the installation and configuration method ...
Preface "High Performance MySQL" mentio...
Click here to return to the 123WORDPRESS.COM HTML ...
Preface The blogger uses the idea IDE. Because th...
Note that this is not a project created by vue-cl...
Problem Description MySQL is started successfully...
1. The relationship between fonts and character d...
Events can specify the execution of SQL code once...
Error occurs: When exporting the database from My...
The docker repository itself is very slow, but th...
Problem: The website published through IIS is pla...
1. Background The following two problems are enco...