Home >Database >Mysql Tutorial >How to Add 2 Hours to the Current Time in MySQL?
Adjusting Time in MySQL: Adding Hours to the Current Time
In MySQL, manipulating dates and times is crucial for various database operations. One common task is adding a certain amount of time to the current time. This article explores the correct syntax for adding 2 hours to the current time in MySQL.
Query Syntax
The valid query syntax for adding 2 hours to the current time in MySQL is:
SELECT * FROM courses WHERE DATE_ADD(NOW(), INTERVAL 2 HOUR) > start_time
Explanation
Example
Consider a courses table with a start_time field to track the start time of each course. To fetch all courses that start within 2 hours of the current time, you would use the following query:
SELECT * FROM courses WHERE DATE_ADD(NOW(), INTERVAL 2 HOUR) > start_time
Additional Notes
The above is the detailed content of How to Add 2 Hours to the Current Time in MySQL?. For more information, please follow other related articles on the PHP Chinese website!