
- 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 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 Articles
- How to convert Python date format to 10-digit date format for mysql?
- How to convert a date format in MySQL?
- How to convert US date format to MySQL format in INSERT query?
- Convert MySQL Unix-Timestamp format to date format?
- How to change date format with DATE_FORMAT() in MySQL?
- How to update a MySQL date type column?
- How to correctly convert a date format into a MySQL date?
- Format date to display month names with the entire date in MySQL?
- How to update date of datetime field with MySQL?
- How to update only day portion of MySQL Date?
- MySQL query to update only month in date?
- Change the curdate() (current date) format in MySQL
- Best way to change the date format in MySQL SELECT?
- Convert VARCHAR data to MySQL date format?
- MySQL ORDER BY Date field not in date format?

Advertisements