
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
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)
- Related Articles
- Select records from MySQL NOW() -1 Day?
- How to make MySQL's NOW() and CURDATE() functions use UTC?
- CURDATE () vs NOW() in MySQL
- How can we add day/s in the date stored in a column of MySQL table?
- Subtracting a day in MySQL
- MySQL DateTime Now()+5 days/hours/minutes/seconds?
- How to Celebrate International Women's Day?
- What is the difference between MySQL NOW() and SYSDATE()?
- What is the difference between MySQL NOW() and CURDATE() function?
- Calling NOW() function to fetch current date records in MySQL?
- How to apply NOW() to timestamps field in MySQL Workbench?
- Display dates after NOW() + 10 days from a MySQL table?
- Set a MySQL field with the current date (UNIX_TIMESTAMP(now))
- What is the history of women's day celebration?
- MySQL select dates in 30-day range?
