Jump to content

Using INTERVAL to select within date range


Ansel_Tk1

Recommended Posts

Hi - wondering if someone out there can give me some guidance.

 

I'm trying to select only those rows where my datetime field is less than or equal to 1 calendar day of todays date (not 24hrs).

 

Basically, I am making a contest entry form where you can only enter the contest once every calendar day. This is what I am using now but the logic seems messed up:

 

SELECT * FROM newssubscribe_details WHERE contestid = %s AND newssubscribe_id = %s AND dateandtime <= CURRENT_DATE() - INTERVAL 1 day

 

Any help would be really appreciated! Thanks.

I love simple logic. That makes sense. Although I am trying this but need to work out how to specify the actual day (todays date):

 

SELECT * FROM newssubscribe_details WHERE contestid = %s AND newssubscribe_id = %s AND dateandtime = DATE(NOW())

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.