- 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
How to insert current date/ time using now() in a field with MySQL?
In MySQL, now() can be used to insert current date/time. The syntax is as follows −
insert into yourTableName values(now());
To understand the above concept of inserting current date/time in the table, let us first create a table −
mysql> create table CurrentDateTimeDemo −> ( −> YourTime datetime −> ); Query OK, 0 rows affected (0.58 sec)
Inserting current date/time using now(). The query is as follows −
mysql> insert into CurrentDateTimeDemo values(now()); Query OK, 1 row affected (0.20 sec)
Now you can check the current date/time has been inserted or not −
mysql> select *from CurrentDateTimeDemo;
The following output displays that the current date is successfully inserted using now():
+---------------------+ | YourTime | +---------------------+ | 2018-12-08 19:08:41 | +---------------------+ 1 row in set (0.00 sec)
- Related Articles
- Set a MySQL field with the current date (UNIX_TIMESTAMP(now))
- How to insert current date/time in MySQL?
- MySQL - Insert current date/time?
- How to insert current date and time in a database using JDBC?
- MySQL query to insert current date plus specific time?
- Insert current time minus 1 hour to already inserted date-time records in MYSQL
- How to Insert custom date into MySQL timestamp field?
- Insert current date to the database in MySQL?
- Calling NOW() function to fetch current date records in MySQL?
- Insert current date in datetime format MySQL?
- Select current time with MySQL now() and convert it to GMT 0?
- How can we insert current date and time automatically on inserting values in other columns in MySQL?
- How to insert date in single quotes with MySQL date formats?
- How to insert date object in MySQL using Python?
- How to print current date and time using Python?

Advertisements