- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the correct DateTime format for a MySQL Database?
The correct datetime format for MySQL database is as follows −
‘YYYY-MM-DD HH:M:SS’
Let us first create a table −
mysql> create table DemoTable797 ( ArrivalDatetime datetime ); Query OK, 0 rows affected (0.68 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable797 values(NOW()); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable797 values('2016-12-21 12:50:34'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable797 values('2017-03-01 17:40:21'); Query OK, 1 row affected (0.24 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable797;
This will produce the following output. We have used NOW() while inserting the first value in the table. The NOW() displays the current date and time −
+---------------------+ | ArrivalDatetime | +---------------------+ | 2019-08-01 21:40:42 | | 2016-12-21 12:50:34 | | 2017-03-01 17:40:21 | +---------------------+ 3 rows in set (0.00 sec)
- Related Articles
- Add10 minutes to MySQL datetime format?
- String format for DateTime in C#
- Insert current date in datetime format MySQL?
- Adding a day to a DATETIME format value in MySQL?
- How do I re-format datetime in MySQL?
- What is the correct syntax for NOT LIKE in MySQL?
- What is a database and what are the advantages of using MySQL database?
- Display USD currency records with the correct format in MySQL
- How to convert string to 24-hour datetime format in MySQL?
- How to convert MySQL DATETIME value to JSON format in JavaScript?
- Setup the format of DATETIME to 'DDMM- YYYY HH:MM:SS' with MySQL SELECT?
- How to use MySQL FROM_UNIXTIME() function to return datetime value in numeric format?
- What is the difference between MySQL DATETIME and TIMESTAMP data type?
- What do you mean by default MySQL database for the user?
- Input type DateTime Value format with HTML

Advertisements