![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
MySQL's now() +1 day?
The statement now()+1 day itself states that we need to add a day to the current datetime. You can write the above logic like this −
now()+interval 1 day;
Or you can write same logic with date_add() function from MySQL like this −
date_add(now(),interval 1 day);
Let us use the above concept with MySQL select statement. The query is as follows −
mysql> select now()+ interval 1 day;
Here is the sample output that increments a day by 1 −
+-----------------------+ | now()+ interval 1 day | +-----------------------+ | 2018-11-23 15:43:10 | +-----------------------+ 1 row in set (0.05 sec)
Now, let us see another example to use the date_add() function for adding a day to the current date.
The query is as follows −
mysql> select date_add(now(),interval 1 day);
Here is the output −
+--------------------------------+ | date_add(now(),interval 1 day) | +--------------------------------+ | 2018-11-23 15:45:43 | +--------------------------------+ 1 row in set (0.00 sec)
For displaying only the date, then you can use the below logic for now()+1 day.
Use curdate(), instead of now().
curdate()+interval 1 day.
Or you can use the above logic with the help of date_add() function.
date_add(curdate(),interval 1 day);
Here is demo of the above two concepts.
mysql> select curdate()+interval 1 day;
Here is the output that displays only the incremented date with curdate() −
+--------------------------+ | curdate()+interval 1 day | +--------------------------+ | 2018-11-23 | +--------------------------+ 1 row in set (0.00 sec)
The date_add() demo −
mysql> select date_add(curdate(),interval 1 day);
Here is the output that displays only the incremented date with date_add() −
+------------------------------------+ | date_add(curdate(),interval 1 day) | +------------------------------------+ | 2018-11-23 | +------------------------------------+ 1 row in set (0.00 sec)