tags:

views:

2545

answers:

3

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*

+5  A: 

You need DATE_SUB() OR DATE_ADD()

Sergii
+3  A: 

The DATE_ADD() function will do the trick. (You can also use the ADDTIME() function if you're running at least v4.1.1.)

lc
+7  A: 
SELECT * 
FROM courses 
WHERE DATE_ADD(NOW(), INTERVAL 2 HOUR) > start_time
glavić