fesan Posted September 3, 2009 Share Posted September 3, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/173022-mysql-where-date/ Share on other sites More sharing options...
rhodesa Posted September 3, 2009 Share Posted September 3, 2009 is the name of the column called 'date'? date is a reserved word in MySQL...you should change the name of the column or use backticks: SELECT * FROM $dbtable WHERE `date` < $today ORDER BY date, getin ASC Quote Link to comment https://forums.phpfreaks.com/topic/173022-mysql-where-date/#findComment-911898 Share on other sites More sharing options...
PFMaBiSmAd Posted September 3, 2009 Share Posted September 3, 2009 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.) Quote Link to comment https://forums.phpfreaks.com/topic/173022-mysql-where-date/#findComment-911900 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.