Jump to content

MySQL Where date <>


fesan

Recommended Posts

Hello...

 

Trying to not show all records that are dated older than today(at any point)

 

My query looks like this:

SELECT * FROM $dbtable WHERE date < $today ORDER BY date, getin ASC

 

This one failes for some reason. When i change the greater/smaler then to >, it gets the correct result.

My, creation of $today looks like this:

$today = date('Y-m-d');

 

I have records where the date field is older and newer than today. My date field has the date format.

 

Can some one tell me why it is failing?

Link to comment
https://forums.phpfreaks.com/topic/173022-mysql-where-date/
Share on other sites

WHERE date < $today selects records that are older than $today (this is the opposite of what you stated you want to select.)

 

WHERE date >= $today selects records that are newer or the same as $today (sounds like you want to do this.)

 

WHERE date > $today selects records that are newer than $today (or this one.)

Link to comment
https://forums.phpfreaks.com/topic/173022-mysql-where-date/#findComment-911900
Share on other sites

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.