Tutorialspoint

1 Answer
Arjun Thakur

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

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.