
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
How can we insert current date automatically in a column of MySQL table?
With the help of CURDATE() and NOW() function, we can insert current date automatically in a column of MySQL table.
Example
Suppose we want to insert current date automatically in an OrderDate column of table year_testing the following query will do this −
mysql> Insert into year_testing (OrderDate) Values(CURDATE()); Query OK, 1 row affected (0.11 sec) mysql> Select * from year_testing; +------------+ | OrderDate | +------------+ | 2017-10-28 | +------------+ 1 row in set (0.00 sec) mysql> Insert into year_testing (OrderDate) Values(NOW()); Query OK, 1 row affected, 1 warning (0.12 sec) mysql> Select * from year_testing; +------------+ | OrderDate | +------------+ | 2017-10-28 | | 2017-10-28 | +------------+ 2 rows in set (0.00 sec)
- Related Questions & Answers
- How can we insert current year automatically in a YEAR type column of MySQL table?
- How can we insert current date and time automatically on inserting values in other columns in MySQL?
- How can we insert data into a MySQL table?
- MySQL - Insert current date/time?
- How can we use INSERT() function to insert a new string into the value of a column of MySQL table?
- How can we add a time interval to date stored in a column of MySQL table?
- How can we add day/s in the date stored in a column of MySQL table?
- How can we modify column/s of MySQL table?
- How can we insert a new row into a MySQL table?
- How to insert current date/time in MySQL?
- How can we remove a column from MySQL table?
- Insert current date in datetime format MySQL?
- How can we automatically define the structure of MySQL table same as the structure of another table?
- How can we put comments in a column of existing MySQL table?
- How can we use MySQL EXPORT_SET() function with column of a table?
Advertisements