 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP 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
Which one should I use? The datetime or timestamp data type in MySQL?
Timestamp is a data type in MySQL and works for different time zone. It is also used for date and time purpose To understand the concept, we need to create a table.
Creating a table
mysql> CREATE table TimeStampDemo -> ( -> MyDataTime timestamp -> ); Query OK, 0 rows affected (0.57 sec)
After creating the table, we will insert a record with the help of INSERT command.
Inserting records
mysql> INSERT into TimeStampDemo values (now()); Query OK, 1 row affected (0.12 sec)
After inserting a record, we can display the records with the help of SELECT statement.
Displaying records
mysql> SELECT * from TimeStampDemo;
After executing the above query, we will get the following output
+---------------------+ | MyDataTime | +---------------------+ | 2018-10-11 17:30:38 | +---------------------+ 1 row in set (0.00 sec)
Advertisements
 