
- 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
In MySQL, how can we display the date in other format specified by the user?
We need to use DATE_FORMAT() function to display the date in other formats. There would be two arguments of this function, first would be the date and second would be the format string.
Example − Suppose in the table ‘date_testing we have three dates in the following format
mysql> Select * from date_testing; +------------+ | Date | +------------+ | 2017-03-15 | | 2017-03-25 | | 2017-04-05 | +------------+ 3 rows in set (0.00 sec)
Now DATE_FORMAT() function will change the format of the above dates in the format given by the user as follows −
mysql> Select DATE_FORMAT(Date, '%W %D %M %Y')AS 'FORMATTED DATE' from date_testing; +---------------------------+ | FORMATTED DATE | +---------------------------+ | Wednesday 15th March 2017 | | Saturday 25th March 2017 | | Wednesday 5th April 2017 | +---------------------------+ 3 rows in set (0.00 sec)
Here in the above example %W, %D, etc. are date format characters.
- Related Articles
- In MySQL, how can we display time in other format specified by the user?
- Format date to display month names with the entire date in MySQL?
- How can we change MySQL user password by using the ALTER USER statement?
- How can we format a date using the Jackson library in Java?
- How can we create a MySQL user account by omitting the hostname?
- MySQL ORDER BY Date field not in date format?
- How can we calculate the Date in MySQL using functions?
- How can we offload the time/date handling in MySQL?
- How can we change MySQL user password by using the SET PASSWORD statement?
- How to update the date format in MySQL?
- How can we retrieve the length of a specified string in MySQL?
- How can we change MySQL user password by using UPDATE statement?
- How can we obtain the part of a date in MySQL?
- How can we retrieve the output having decimal values of a column in a specified format?
- How can we create user accounts in MySQL database server?

Advertisements