Display rows from MySQL where a datetime is within the next hour

Posted by alex on Stack Overflow See other posts from Stack Overflow or by alex
Published on 2010-04-15T05:13:33Z Indexed on 2010/04/15 5:23 UTC
Read the original article Hit count: 212

Filed under:
|
|

I always have trouble with complicated SQL queries.

This is what I have

$query = '
            SELECT id,
                   name, 
                   info, 
                   date_time
            FROM acms_events
                WHERE date_time = DATE_SUB(NOW(), INTERVAL 1 HOUR)
                    AND active = 1
            ORDER BY date_time ASC
            LIMIT 6
        ';

I want to get up to 6 rows that are upcoming within the hour. Is my query wrong? It does not seem to get events that are upcoming within the next hour when I test it.

What is the correct syntax for this?

Thanks

© Stack Overflow or respective owner

Related posts about mysql

Related posts about query