- 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
How to update a MySQL date type column?
Let us first create a table −
mysql> create table DemoTable1451 -> ( -> JoiningDate date -> ); Query OK, 0 rows affected (0.52 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1451 values('2019-07-21'); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable1451 values('2018-01-31'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable1451 values('2017-06-01'); Query OK, 1 row affected (0.20 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1451;
This will produce the following output −
+-------------+ | JoiningDate | +-------------+ | 2019-07-21 | | 2018-01-31 | | 2017-06-01 | +-------------+ 3 rows in set (0.00 sec)
Here is the query to update a date type column. We are incrementing the date records with an year −
mysql> update DemoTable1451 set JoiningDate=date_add(JoiningDate, interval 1 year); Query OK, 3 rows affected (0.15 sec) Rows matched: 3 Changed: 3 Warnings: 0
Let us check the table records once again −
mysql> select * from DemoTable1451;
This will produce the following output −
+-------------+ | JoiningDate | +-------------+ | 2020-07-21 | | 2019-01-31 | | 2018-06-01 | +-------------+ 3 rows in set (0.00 sec)
- Related Articles
- Update MySQL table column by matching date using date() function?
- How to update a column of varchar type in MySQL to increase its length?
- How to update the date format in MySQL?
- Find date record after a particular date from a column with VARCHAR type in MySQL
- How MySQL evaluates if I store date along with time value in a column having DATE data type?
- How to update date of datetime field with MySQL?
- How to update only day portion of MySQL Date?
- How to update MySQL column with random value?
- Perform MySQL UPDATE on the basis of DATE value in another column
- How to update a MySQL table by swapping two column values?
- Update a column based on another MySQL table’s column
- MySQL query to update only month in date?
- Update a MySQL column with JSON format?
- How to update records in a column with random numbers in MySQL?
- How to update a MySQL column by subtracting a value with some conditions?

Advertisements