- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- 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
MySQL query to insert current date plus specific time?
You can use CONCAT() for this. The syntax is as follows −
insert into DemoTable values(concat(curdate(), ' yourSpecificTime’));
Let us first create a table −
mysql> create table DemoTable ( ArrivalDate datetime ); Query OK, 0 rows affected (1.06 sec)
Insert some records in the table using insert command. We are adding the current date and time −
mysql> insert into DemoTable values(concat(curdate(), ' 10:20:05')); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values(concat(curdate(), ' 12:05:00')); Query OK, 1 row affected (0.17 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
+---------------------+ | ArrivalDate | +---------------------+ | 2019-06-08 10:20:05 | | 2019-06-08 12:05:00 | +---------------------+ 2 rows in set (0.00 sec)
Advertisements