

- 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
How to update the date format in MySQL?
Let us first create a table −
mysql> create table DemoTable630 (ArrivalDate varchar(100)); Query OK, 0 rows affected (0.55 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable630 values('2015-21-01'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable630 values('2018-25-12'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable630 values('2019-15-07'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable630 values('2016-31-03'); Query OK, 1 row affected (0.17 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable630;
This will produce the following output −
+-------------+ | ArrivalDate | +-------------+ | 2015-21-01 | | 2018-25-12 | | 2019-15-07 | | 2016-31-03 | +-------------+ 4 rows in set (0.00 sec)
Following is the query to convert date format −
mysql> select str_to_date(ArrivalDate,'%Y-%d-%m') from DemoTable630;
This will produce the following output −
+-------------------------------------+ | str_to_date(ArrivalDate,'%Y-%d-%m') | +-------------------------------------+ | 2015-01-21 | | 2018-12-25 | | 2019-07-15 | | 2016-03-31 | +-------------------------------------+ 4 rows in set (0.00 sec)
- Related Questions & Answers
- How to convert Python date format to 10-digit date format for mysql?
- How to convert a date format in MySQL?
- Convert MySQL Unix-Timestamp format to date format?
- How to convert US date format to MySQL format in INSERT query?
- How to update a MySQL date type column?
- How to change date format with DATE_FORMAT() in MySQL?
- Format date to display month names with the entire date in MySQL?
- How to correctly convert a date format into a MySQL date?
- Change the curdate() (current date) format in MySQL
- How to update date of datetime field with MySQL?
- How to update only day portion of MySQL Date?
- Convert VARCHAR data to MySQL date format?
- Best way to change the date format in MySQL SELECT?
- MySQL query to update only month in date?
- MySQL ORDER BY Date field not in date format?
Advertisements