

- 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
How to convert MM/YY to YYYY-MM-DD in MYSQL?
To convert, use str_to_date() in MySQL
Let us create a table and add date records −
Example
mysql> create table demo72 -> ( -> due_date varchar(40) -> ); Query OK, 0 rows affected (2.96 sec)
Insert some records into the table with the help of insert command −
Example
mysql> insert into demo72 values("11/15"); Query OK, 1 row affected (0.26 sec) mysql> insert into demo72 values("02/20"); Query OK, 1 row affected (0.09 sec) mysql> insert into demo72 values("07/95"); Query OK, 1 row affected (0.15 sec)
Display records from the table using select statement −
Example
mysql> select *from demo72;
This will produce the following output −
Output
+----------+ | due_date | +----------+ | 11/15 | | 02/20 | | 07/95 | +----------+ 3 rows in set (0.00 sec)
Following is the query to convert MM/YY to YYYY-MM-DD in MySQL.
Example
mysql> select str_to_date(concat('10/', due_date), '%d/%m/%y') as original_date -> from demo72;
This will produce the following output −
Output
+---------------+ | original_date | +---------------+ | 2015-11-10 | | 2020-02-10 | | 1995-07-10 | +---------------+ 3 rows in set (0.00 sec)
- Related Questions & Answers
- How to convert MM/YY to YYYY-MM-DD with a specific day in MySQL?
- Convert MySQL date format from yyyy-mm-ddThh:mm:ss.sssZ to yyyy-mm-dd hh:mm:ss ?
- Convert MM/DD/YY to Unix timestamp in MySQL?
- MySQL - Convert YYYY-MM-DD to UNIX timestamp
- MySQL query to convert YYYY-MM-DD to DD Month, YYYY date format
- MySQL date format to convert dd.mm.yy to YYYY-MM-DD?
- How to convert date YYYYMMDD to YY-MM-DD in MySQL query?
- Convert dd/mm/yyyy string to Unix timestamp in MySQL?
- How to parse Date from String in the format: dd/MM/yyyy to dd/MM/yyyy in java?
- How to insert mm/dd/yyyy format dates in MySQL?
- How to convert Python date string mm/dd/yyyy to datetime?
- MySQL date format DD/MM/YYYY select query?
- How to format JavaScript date into yyyy-mm-dd format?
- Get date format DD/MM/YYYY with MySQL Select Query?
- Java Program to format date in mm-dd-yyyy hh:mm:ss format
Advertisements