delphi123 Posted November 1, 2009 Share Posted November 1, 2009 Any ideas what's wrong with this? SELECT jos_content.title, jos_content.introtext, jos_content.id, jos_content.publish_up, jos_content.hits, jos_content.catid, jos_content.sectionid, jos_content.state FROM jos_content WHERE jos_content.publish_up + interval 7 day < now() ORDER BY jos_content.publish_up DESC I'm trying to get articles published in the last week, but it's either returning everything or nothing depending which way I put the greater/less than in the WHERE statement (have tried both)... Quote Link to comment https://forums.phpfreaks.com/topic/179827-solved-newer-than-one-week-query-not-working/ Share on other sites More sharing options...
Mchl Posted November 1, 2009 Share Posted November 1, 2009 DATE_ADD(now(),interval -7 day) > jos_content.publish_up Quote Link to comment https://forums.phpfreaks.com/topic/179827-solved-newer-than-one-week-query-not-working/#findComment-948682 Share on other sites More sharing options...
delphi123 Posted November 1, 2009 Author Share Posted November 1, 2009 Hi Mchl, Yeah had tried it with DATE_ADD originally, but it's still doing the same thing... So I've now got: SELECT jos_content.title, jos_content.introtext, jos_content.id, jos_content.publish_up, jos_content.hits, jos_content.catid, jos_content.sectionid, jos_content.state FROM jos_content WHERE DATE_ADD(now(),interval -7 day) > jos_content.publish_up ORDER BY jos_content.publish_up DESC Quote Link to comment https://forums.phpfreaks.com/topic/179827-solved-newer-than-one-week-query-not-working/#findComment-948684 Share on other sites More sharing options...
PFMaBiSmAd Posted November 1, 2009 Share Posted November 1, 2009 You need to post the column definition and/or an example of what is in the column. Quote Link to comment https://forums.phpfreaks.com/topic/179827-solved-newer-than-one-week-query-not-working/#findComment-948690 Share on other sites More sharing options...
delphi123 Posted November 1, 2009 Author Share Posted November 1, 2009 I've also tried setting the date through php, but that's doing the same thing: $query="SELECT * FROM jos_content WHERE publish_up <= '".date("Y-m-d",mktime(0,0,0,date("n"),date("j")-7,date("Y")))."' ORDER BY jos_content.publish_up DESC"; echo "<h3>This query returns:</h3>"; echo $query; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<h3>Query Returns:</h3><table>"; $i=0; while ($i < $num) { $title=mysql_result($result,$i,"title"); $publish_up=mysql_result($result,$i,"publish_up"); echo "<tr><td>$title</td> <td>$publish_up</td></tr>"; $i++; } Very strange... Here's the first line of the two columns: $title = Artbeats: royalty-free stock footage / varchar $publish_up = 2009-10-14 18:12:56 /datetime Quote Link to comment https://forums.phpfreaks.com/topic/179827-solved-newer-than-one-week-query-not-working/#findComment-948692 Share on other sites More sharing options...
delphi123 Posted November 1, 2009 Author Share Posted November 1, 2009 oh damn, just realised I'm connected to the dev database, not the one I though I was - so there are no articles newer than a week! Feel free to all hit the 'pound the idiot forum poster' button! (hey that'd be a great feature to these forums ;o) ) Quote Link to comment https://forums.phpfreaks.com/topic/179827-solved-newer-than-one-week-query-not-working/#findComment-948694 Share on other sites More sharing options...
Mchl Posted November 1, 2009 Share Posted November 1, 2009 Feel free to all hit the 'pound the idiot forum poster' button! (hey that'd be a great feature to these forums ;o) ) You can suggest it in PHPFreaks.com Questions, Comments, & Suggestions section. Cheers Quote Link to comment https://forums.phpfreaks.com/topic/179827-solved-newer-than-one-week-query-not-working/#findComment-948703 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.