- 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
Show date like 30-04-2020 instead of 2020-04-30 from MySQL database?
For this, use DATE_FORMAT() in MySQL. The syntax is as follows −
Example
select date_format(yourColumnName,'%d-%m-%Y') as anyAliasName from yourTableName;
Let us create a table −
Example
mysql> create table demo80 -> ( -> due_date date -> ); Query OK, 0 rows affected (0.74
Insert some records into the table with the help of insert command −
Example
mysql> insert into demo80 values('2020-04-30'); Query OK, 1 row affected (0.14 mysql> insert into demo80 values('2016-01-10'); Query OK, 1 row affected (0.17 mysql> insert into demo80 values('2018-03-21'); Query OK, 1 row affected (0.12
Display records from the table using select statement −
Example
mysql> select *from demo80;
This will produce the following output −
Output
+------------+
| due_date |+------------+
| 2020-04-30 || 2016-01-10 |
| 2018-03-21 |+------------+
3 rows in set (0.00 sec)
Following is the query to show date like 30-04-2020 instead of 2020-04-30.
Example
mysql> select date_format(due_date,'%d-%m-%Y') as ShowDate from demo80;
This will produce the following output −
Output
+------------+
| ShowDate |+------------+
| 30-04-2020 || 10-01-2016 |
| 21-03-2018 |+------------+
3 rows in set (0.03 sec)
- Related Articles
- MySQL - Changing year of dates from 2020 to 2011?
- How can I display Java date as '12/04/2019'
- Find A, if ( 2020^{20}-2020^{19}=2020^{19} times mathrm{A} ).
- How to select a query for a selected day(2010-11-04) to current date using MySQL?
- MySQL query to delete a DATE older than 30 days from another date?
- Evaluate: $[(2020) + (2021) + (2022)]$
- How to set up openvpn on ubuntu 16 04
- Add 30 days to date in a MySQL table with arrival date records
- Upskilling: The Sure Shot Career Mantra for 2020
- How is it possible to store date such as February 30 in a MySQL date column?
- Facebook Marketing Strategy 2020 You Should Implement for Your Business
- GATE 2020: How to Prepare, What’s New and Preparation Tips
- Latest CSS Properties and APIs for Web Design in 2020
- MySQL query to extract only the day instead of entire date
- How to subtract 30 days from the current datetime in MySQL?

Advertisements