
- 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
How to convert a string to date in MySQL?
We can convert a string to date with the help of STR_TO_DATE() function. Let us see an example.
Creating a table.
mysql> create table StringToDateDemo -> ( -> YourDate varchar(100) -> ); Query OK, 0 rows affected (0.49 sec)
Inserting records into the table.
mysql> insert into StringToDateDemo values('10/27/2018'); Query OK, 1 row affected (0.11 sec)
The following is the syntax to convert string to date using the STR_TO_DATE() function.
SELECT STR_TO_DATE(yourColumnName, '%m/%d/%Y') from yourTableName;
Let us now implement it.
mysql>SELECT STR_TO_DATE(YourDate, '%m/%d/%Y') -> from StringToDateDemo;
Here is the output.
+-----------------------------------+ | STR_TO_DATE(YourDate, '%m/%d/%Y') | +-----------------------------------+ | 2018-10-27 | +-----------------------------------+ 1 row in set (0.00 sec)
- Related Articles
- How to convert a MySQL date to JavaScript date?
- How to convert a Python date string to a date object?
- How to convert a date format in MySQL?
- How to convert String to Date in java?
- How to Convert Date to String in TypeScript?
- How to convert a Date value to string in JDBC?
- How to convert a string in to date object in JavaScript?
- How to convert a JavaScript date object to a string?
- How to correctly convert a date format into a MySQL date?
- How to convert Date to String in Java 8?
- Convert UK DATE to MySQL date?
- Convert String to Date in Java
- Set format specifier in MySQL STR_TO_DATE() and convert string to date
- Java Program to convert a String to Date
- Convert varchar to date in MySQL?

Advertisements