Jump to content

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


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.