

- 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 insert mm/dd/yyyy format dates in MySQL?
For this, use STR_TO_DATE(). Following is the syntax −
insert into yourTableName values(STR_TO_DATE(yourDateValue,yourFormatSpecifier));
Let us first create a table −
mysql> create table DemoTable ( ShippingDate date ); Query OK, 0 rows affected (0.81 sec)
Insert some records in the table using insert command : Here, we are inserting formatted dates using date formats like m, d, y, etc −
mysql> insert into DemoTable values(STR_TO_DATE('06-01-2019', '%m-%d-%Y')); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values(STR_TO_DATE('01-31-2019', '%m-%d-%Y')); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values(STR_TO_DATE('02-01-2018', '%m-%d-%Y')); Query OK, 1 row affected (0.27 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
+--------------+ | ShippingDate | +--------------+ | 2019-06-01 | | 2019-01-31 | | 2018-02-01 | +--------------+ 3 rows in set (0.00 sec)
- Related Questions & Answers
- MySQL query to convert YYYY-MM-DD to DD Month, YYYY date format
- Convert MySQL date format from yyyy-mm-ddThh:mm:ss.sssZ to yyyy-mm-dd hh:mm:ss ?
- MySQL date format DD/MM/YYYY select query?
- How to format JavaScript date into yyyy-mm-dd format?
- How to parse Date from String in the format: dd/MM/yyyy to dd/MM/yyyy in java?
- MySQL date format to convert dd.mm.yy to YYYY-MM-DD?
- Get date format DD/MM/YYYY with MySQL Select Query?
- How to convert MM/YY to YYYY-MM-DD in MYSQL?
- Java Program to format date in mm-dd-yyyy hh:mm:ss format
- MySQL - Convert YYYY-MM-DD to UNIX timestamp
- Get today's date in (YYYY-MM-DD) format in MySQL?
- Program to reformat date in YYYY-MM-DD format using Python
- Accepting date strings (MM-dd-yyyy format) using Java regex?
- Change date format (in DB or output) to dd/mm/yyyy in PHP MySQL?
- Convert dd/mm/yyyy string to Unix timestamp in MySQL?
Advertisements