acidglitter Posted July 18, 2006 Share Posted July 18, 2006 How can I only show things from a table that are at least one month old? The row or whatever that shows the dates is the "date" type Quote Link to comment Share on other sites More sharing options...
willfitch Posted July 18, 2006 Share Posted July 18, 2006 SELECT * FROM table WHERE date_field > CURDATE() Quote Link to comment Share on other sites More sharing options...
acidglitter Posted July 19, 2006 Author Share Posted July 19, 2006 hmm I tried that but it didn't work :( Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 19, 2006 Share Posted July 19, 2006 SELECT something FROM tbl_name WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) Quote Link to comment Share on other sites More sharing options...
acidglitter Posted August 15, 2006 Author Share Posted August 15, 2006 So I tried that and I changed everything except forWHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY)Instead of limiting what it showed to things that are at least a month old, it just showed EvEryThiNG :( Quote Link to comment Share on other sites More sharing options...
acidglitter Posted August 17, 2006 Author Share Posted August 17, 2006 [size=6pt]*bump*[/size] Quote Link to comment Share on other sites More sharing options...
HeyRay2 Posted August 18, 2006 Share Posted August 18, 2006 [b]redarrow[/b]'s example, from [url=http://www.mysql.org/doc/refman/4.1/en/date-and-time-functions.html]MySQL.org[/url], is missing a comparison. Otherwise, it should work fine. Try this:[code]<?php$query = "SELECT something FROM tbl_name WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= date_col";?>[/code] Quote Link to comment Share on other sites More sharing options...
acidglitter Posted September 16, 2006 Author Share Posted September 16, 2006 gr this is irritating.. So it looks like this now[code]$sql=mysql_query("SELECT * FROM losers WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= lastused");[/code]Maybe I should just select everything and then put LIMIT TO something..? Quote Link to comment 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.