
- 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
How to add 1 day to the date in MySQL?
We can add 1 day to the date with the help of DATE_ADD() function.
Creating a table.
mysql> create table Add1DayDemo -> ( -> id int, -> MyDate datetime not null -> ); Query OK, 0 rows affected (1.06 sec)
Insert some records.
mysql> insert into Add1DayDemo values(1,now()); Query OK, 1 row affected (0.08 sec) mysql> insert into Add1DayDemo values(2,date_add(now(),interval 5 day)); Query OK, 1 row affected (0.16 sec)
To display all records.
mysql> select *from Add1DayDemo;
The following is the output.
+------+---------------------+ | id | MyDate | +------+---------------------+ | 1 | 2018-10-30 10:51:21 | | 2 | 2018-11-04 10:51:30 | +------+---------------------+ 2 rows in set (0.00 sec)
To add 1 day in field “MyDate”, use the SELECT
mysql> SELECT DATE_ADD(`MyDate`, INTERVAL 1 DAY) from Add1DayDemo -> where id=2;
The following is the output that shows the day, which was 4th November, increments by one, since we added a day.
+------------------------------------+ | DATE_ADD(`MyDate`, INTERVAL 1 DAY) | +------------------------------------+ | 2018-11-05 10:51:30 | +------------------------------------+ 1 row in set (0.00 sec)
- Related Articles
- How add 1 day to Date in swift?
- How to add a day to the date in MySQL?
- How to add 1 day to a Date in iOS/iPhone?
- How to select rows in MySQL that are >= 1 DAY from the current date?
- How to update only day portion of MySQL Date?
- How to add a day to datetime field in MySQL query?
- How can we add day/s in the date stored in a column of MySQL table?
- How to display first day and last day of the month from date records in MySQL?
- How to use date command in day to day practical usage
- MySQL add days to a date?
- How to add current date to an existing MySQL table?
- JavaScript program to decrement a date by 1 day
- How to add +1 to existing MySQL values?
- How can I add one day to DATETIME field in MySQL query?
- Add two weeks to a date in MySQL?

Advertisements