
- 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
Convert MySQL date format from yyyy-mm-ddThh:mm:ss.sssZ to yyyy-mm-dd hh:mm:ss ?
Let us first create a table −
mysql> create table DemoTable668(JoiningDate varchar(200)); Query OK, 0 rows affected (0.97 sec)
Insert some records in the table using insert command. We have inserted date in the format yyyy-mm-ddThh:mm:ss.sssZ −
mysql> insert into DemoTable668 values('2001-01-10T06:20:00.000Z'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable668 values('2019-07-20T04:00:00.000Z'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable668 values('2016-02-12T05:10:50.000Z'); Query OK, 1 row affected (0.17 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable668;
This will produce the following output −
+--------------------------+ | JoiningDate | +--------------------------+ | 2001-01-10T06:20:00.000Z | | 2019-07-20T04:00:00.000Z | | 2016-02-12T05:10:50.000Z | +--------------------------+ 3 rows in set (0.00 sec)
Following is the query to convert the date format from yyyy-mm-ddThh:mm:ss.sssZ to yyyy-mm-dd hh:mm:ss −
mysql> update DemoTable668 SET JoiningDate = DATE_FORMAT(STR_TO_DATE(JoiningDate,'%Y-%m-%dT%H:%i:%s.000Z'),'%Y-%m-%d %H:%i:%s'); Query OK, 3 rows affected (0.11 sec) Rows matched: 3 Changed: 3 Warnings: 0
Let us check table records once again −
mysql> select *from DemoTable668;
This will produce the following output −
+---------------------+ | JoiningDate | +---------------------+ | 2001-01-10 06:20:00 | | 2019-07-20 04:00:00 | | 2016-02-12 05:10:50 | +---------------------+ 3 rows in set (0.00 sec)
- Related Articles
- MySQL query to convert YYYY-MM-DD to DD Month, YYYY date format
- Java Program to format date in mm-dd-yyyy hh:mm:ss format
- MySQL date format to convert dd.mm.yy to YYYY-MM-DD?
- MySQL date format DD/MM/YYYY select query?
- How to parse Date from String in the format: dd/MM/yyyy to dd/MM/yyyy in java?
- Get date format DD/MM/YYYY with MySQL Select Query?
- How to format JavaScript date into yyyy-mm-dd format?
- MySQL - Convert YYYY-MM-DD to UNIX timestamp
- How to convert MM/YY to YYYY-MM-DD in MYSQL?
- Accepting date strings (MM-dd-yyyy format) using Java regex?
- Get today's date in (YYYY-MM-DD) format in MySQL?
- How to insert mm/dd/yyyy format dates in MySQL?
- Program to reformat date in YYYY-MM-DD format using Python
- How to convert Python date string mm/dd/yyyy to datetime?
- How to Convert YYYY-MM-DD to Standard Date in Excel?

Advertisements