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 Link to comment https://forums.phpfreaks.com/topic/14967-help-with-mysql-queries-and-dates/ Share on other sites More sharing options...
willfitch Posted July 18, 2006 Share Posted July 18, 2006 SELECT * FROM table WHERE date_field > CURDATE() Link to comment https://forums.phpfreaks.com/topic/14967-help-with-mysql-queries-and-dates/#findComment-60117 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 :( Link to comment https://forums.phpfreaks.com/topic/14967-help-with-mysql-queries-and-dates/#findComment-60356 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) Link to comment https://forums.phpfreaks.com/topic/14967-help-with-mysql-queries-and-dates/#findComment-60358 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 :( Link to comment https://forums.phpfreaks.com/topic/14967-help-with-mysql-queries-and-dates/#findComment-74893 Share on other sites More sharing options...
acidglitter Posted August 17, 2006 Author Share Posted August 17, 2006 [size=6pt]*bump*[/size] Link to comment https://forums.phpfreaks.com/topic/14967-help-with-mysql-queries-and-dates/#findComment-76520 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] Link to comment https://forums.phpfreaks.com/topic/14967-help-with-mysql-queries-and-dates/#findComment-76523 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..? Link to comment https://forums.phpfreaks.com/topic/14967-help-with-mysql-queries-and-dates/#findComment-92884 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.