

- 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
Change the curdate() (current date) format in MySQL
The current date format is ‘YYYY-mm-dd’. To change current date format, you can use date_format().
Let us first display the current date −
mysql> select curdate();
This will produce the following output −
+------------+ | curdate() | +------------+ | 2019-08-08 | +------------+ 1 row in set (0.00 sec)
Following is the query to change curdate() (current date) format −
mysql> select date_format(curdate(), '%m/%d/%Y');
This will produce the following output −
+------------------------------------+ | date_format(curdate(), '%m/%d/%Y') | +------------------------------------+ | 08/08/2019 | +------------------------------------+ 1 row in set (0.00 sec)
Let us first create a table −
mysql> create table DemoTable ( ArrivalDate date ); Query OK, 0 rows affected (0.50 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('2019-01-10'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('2016-12-18'); Query OK, 1 row affected (0.12 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-------------+ | ArrivalDate | +-------------+ | 2019-01-10 | | 2016-12-18 | +-------------+ 2 rows in set (0.00 sec)
Following is the query to change date format −
mysql> select date_format(ArrivalDate, '%m/%d/%Y') from DemoTable;
This will produce the following output −
+--------------------------------------+ | date_format(ArrivalDate, '%m/%d/%Y') | +--------------------------------------+ | 01/10/2019 | | 12/18/2016 | +--------------------------------------+ 2 rows in set (0.00 sec)
- Related Questions & Answers
- Insert current date in datetime format MySQL?
- Best way to change the date format in MySQL SELECT?
- Change date format in MongoDB
- How to change date format with DATE_FORMAT() in MySQL?
- PHP program to change the date format
- PHP program to change date format
- Change date format in MySQL database table to d/m/y
- How to change date time format in HTML5?
- Select dates between current date and 3 months from the current date in MySQL?
- How to update the date format in MySQL?
- MySQL - Insert current date/time?
- CURDATE () vs NOW() in MySQL
- Insert current date to the database in MySQL?
- Display Timestamp before the current date in MySQL
- Is there a way to change the date format in php?
Advertisements