Add 2 hours to current time in MySQL?

Ei Maung picture Ei Maung · Feb 26, 2009 · Viewed 236.8k times · Source

Which is the valid syntax of this query in MySQL?

SELECT * FROM courses WHERE (now() + 2 hours) > start_time

note: start_time is a field of courses table

Answer

Glavić picture Glavić · Feb 26, 2009
SELECT * 
FROM courses 
WHERE DATE_ADD(NOW(), INTERVAL 2 HOUR) > start_time

See Date and Time Functions for other date/time manipulation.