 
  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
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
 