Add 2 hours to current time in MySQL?


We can get the current time with the help of now() and adding 2 hours is done by giving the interval as 2. Firstly, collect information of the current time in the system with the help of now(). The current time is .

 Current Time

The following is the query to get the current date and time.

mysql> select now();

Here is the output.

+---------------------+
| now()               |
+---------------------+
| 2018-11-01 12:58:40 |
+---------------------+
1 row in set (0.00 sec)

To add 2 hours in the current time, we will use the DATE_ADD() function.

mysql> select DATE_ADD(now(),interval 2 hour);

The following is the output that displays.

+---------------------------------+
| DATE_ADD(now(),interval 2 hour) |
+---------------------------------+
| 2018-11-01 14:58:31             |
+---------------------------------+
1 row in set (0.00 sec)

Updated on: 30-Jul-2019

8K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements