
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Insert Current Date Plus Specific Time in MySQL
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