
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Easily Insert DateTime in MySQL
You can easily insert DateTime with the MySQL command line. Following is the syntax −
insert into yourTableName values(‘yourDateTimeValue’);
Let us first create a table −
mysql> create table DemoTable ( DateOfBirth datetime ); Query OK, 0 rows affected (0.97 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('1998-01-23 12:45:56'); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable values('2010-12-31 01:15:00'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('2015-04-03 14:00:45'); Query OK, 1 row affected (0.10 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+---------------------+ | DateOfBirth | +---------------------+ | 1998-01-23 12:45:56 | | 2010-12-31 01:15:00 | | 2015-04-03 14:00:45 | +---------------------+ 3 rows in set (0.00 sec)
Advertisements