

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Add a single day to datetime field with MySQL INTERVAL
Let us first create a table −
mysql> create table DemoTable -> ( -> DueDate date ->); Query OK, 0 rows affected (2.11 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('2019-01-21'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('2018-12-31'); Query OK, 1 row affected (0.47 sec) mysql> insert into DemoTable values('2018-12-30'); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable values('2017-02-26'); Query OK, 1 row affected (0.47 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+------------+ | DueDate | +------------+ | 2019-01-21 | | 2018-12-31 | | 2018-12-30 | | 2017-02-26 | +------------+ 4 rows in set (0.00 sec)
Here is the query to add a day to DateTime field in MySQL table −
mysql> update DemoTable -> set DueDate=date_add(DueDate,interval 1 day); Query OK, 4 rows affected (0.21 sec) Rows matched: 4 Changed: 4 Warnings: 0
Let us check the table records once again.
mysql> select *from DemoTable;
This will produce the following output −
+------------+ | DueDate | +------------+ | 2019-01-22 | | 2019-01-01 | | 2018-12-31 | | 2017-02-27 | +------------+ 4 rows in set (0.00 sec)
- Related Questions & Answers
- How to add a day to datetime field in MySQL query?
- How can I add one day to DATETIME field in MySQL query?
- Add DATE and TIME fields to get DATETIME field in MySQL?
- MySQL Datetime to add days?
- How to update date of datetime field with MySQL?
- Adding a day to a DATETIME format value in MySQL?
- Insert datetime into another datetime field in MySQL?
- How to convert char field to datetime field in MySQL?
- Compare DATE string with string from MySQL DATETIME field?
- How to add time in a MySQL column set with type DATETIME?
- Compare only day and month with date field in MySQL?
- How to add a day to the date in MySQL?
- Return a list from different rows into a single field with MySQL
- How to ORDER BY FIELD with GROUP BY in a single MySQL query?
- How to add 30 minutes to datetime in MySQL?
Advertisements