- 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
Change date format in MySQL database table to d/m/y
Following is the syntax −
select date_format(yourColumnName,'%d/%m/%Y') as anyAliasName from yourTableName;
Let us first create a table −
mysql> create table DemoTable ( AdmissionDate date ); Query OK, 0 rows affected (0.89 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('2019-01-21'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('2019-09-09'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('2018-12-31'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('2017-11-01'); Query OK, 1 row affected (0.16 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+---------------+ | AdmissionDate | +---------------+ | 2019-01-21 | | 2019-09-09 | | 2018-12-31 | | 2017-11-01 | +---------------+ 4 rows in set (0.00 sec)
Following is the query to change date format to d/m/y format −
mysql> select date_format(AdmissionDate,'%d/%m/%Y') as AdmissionDate from DemoTable;
This will produce the following output −
+---------------+ | AdmissionDate | +---------------+ | 21/01/2019 | | 09/09/2019 | | 31/12/2018 | | 01/11/2017 | +---------------+ 4 rows in set (0.00 sec)
- Related Articles
- How to change date format with DATE_FORMAT() in MySQL?
- Change the curdate() (current date) format in MySQL
- Best way to change the date format in MySQL SELECT?
- Change date format in MongoDB
- PHP program to change date format
- How to change the date in a table with date records with MySQL?
- How to change date time format in HTML5?
- PHP program to change the date format
- Change date format (in DB or output) to dd/mm/yyyy in PHP MySQL?
- Get the date/time of the last change to a MySQL database?
- Convert MySQL Unix-Timestamp format to date format?
- How to convert Python date format to 10-digit date format for mysql?
- How to change format of dates in a table column with a MySQL query?
- How to change date and time format in Android sqlite?
- How to convert US date format to MySQL format in INSERT query?

Advertisements