Jump to content

trying to get posts from "now" and past 24 hours


monkeytooth

Recommended Posts

SELECT *
FROM votelog
WHERE ipaddress = '127.0.0.1'
AND datevoted
BETWEEN DATE_SUB( CURDATE( ) , INTERVAL 24 HOUR )
AND CURDATE( )
LIMIT 0 , 30

 

That is an example of the query I am attempting to run to find posts within the past 24 hours. I am also running a separate one for different needs for in the past 60 minutes. Issue is there is at least 4 rows in the table I am testing with 3 of which fall under the 24 hour clause.

 

this is what the timestamp in the DB looks like, standard DATETIME.. 2011-09-01 13:20:08

 

with that being said I am yielding no results, well as far as

mysql_num_rows($result)

seems to be concerned..

Figured out my own answer.. it was lousy use of between and curdate()..

 

For those curious the working result would resemble:

 

SELECT *
FROM votelog
WHERE ipaddress = '127.0.0.1'
AND 
BETWEEN DATE_SUB( datevoted , INTERVAL 24 HOUR )
LIMIT 0 , 30

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.