- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 Datetime to add days?
Let us first create a table −
mysql> create table DemoTable1871 ( ArrivalDate datetime ); Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1871 values('2019-12-19 7:45:00'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1871 values('2018-11-10 12:00:00'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1871 values('2019-01-31'); Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1871;
This will produce the following output −
+---------------------+ | ArrivalDate | +---------------------+ | 2019-12-19 07:45:00 | | 2018-11-10 12:00:00 | | 2019-01-31 00:00:00 | +---------------------+ 3 rows in set (0.00 sec)
Here is the query to add days −
mysql> update DemoTable1871 set ArrivalDate=date_add(ArrivalDate, interval 6 day); Query OK, 3 rows affected (0.00 sec) Rows matched: 3 Changed: 3 Warnings: 0
Let us check table records once again −
mysql> select * from DemoTable1871;
This will produce the following output −
+---------------------+ | ArrivalDate | +---------------------+ | 2019-12-25 07:45:00 | | 2018-11-16 12:00:00 | | 2019-02-06 00:00:00 | +---------------------+ 3 rows in set (0.00 sec)
- Related Articles
- C# DateTime to add days to the current date
- MySQL add days to a date?
- MySQL DateTime Now()+5 days/hours/minutes/seconds?
- How to subtract 30 days from the current datetime in MySQL?
- How to subtract 10 days from the current datetime in MySQL?
- How to add 30 minutes to datetime in MySQL?
- Add 11 days to current date in MySQL
- How to add some days to str_to_date() MySQL function?
- MySQL update datetime column values and add 10 years 3 months 22 days and 10 hours, 30 minutes to existing data?
- Add a single day to datetime field with MySQL INTERVAL
- Fetch datetime row from exactly past 7 days records in MySQL
- How to add a day to datetime field in MySQL query?
- Add DATE and TIME fields to get DATETIME field in MySQL?
- Add 30 days to a value in a MySQL table?
- How can I add one day to DATETIME field in MySQL query?

Advertisements