debuitls Posted August 25, 2009 Share Posted August 25, 2009 Hi, I'm trying to return all records from a mysql table that have a timestamp of within the last 24hrs. $result = mysql_query("SELECT * FROM table WHERE where time >= NOW()- INTERVAL 1 DAY"); Just wondering if anybody can see off the top of their head why the above isnt working? any suggestion would be much appreciated Link to comment https://forums.phpfreaks.com/topic/171777-solved-returning-all-records-made-within-the-last-24hrs/ Share on other sites More sharing options...
Adam Posted August 25, 2009 Share Posted August 25, 2009 What data type is "time"? Link to comment https://forums.phpfreaks.com/topic/171777-solved-returning-all-records-made-within-the-last-24hrs/#findComment-905786 Share on other sites More sharing options...
debuitls Posted August 25, 2009 Author Share Posted August 25, 2009 Sorry I should of said that in my original post. Its a timestamp. Link to comment https://forums.phpfreaks.com/topic/171777-solved-returning-all-records-made-within-the-last-24hrs/#findComment-905790 Share on other sites More sharing options...
Adam Posted August 25, 2009 Share Posted August 25, 2009 Ha, are you aware there's 2 wheres in there? You could also use: SELECT * FROM table WHERE time >= DATE_SUB(CURDATE(), INTERVAL 1 DAY) Link to comment https://forums.phpfreaks.com/topic/171777-solved-returning-all-records-made-within-the-last-24hrs/#findComment-905797 Share on other sites More sharing options...
debuitls Posted August 25, 2009 Author Share Posted August 25, 2009 ah shoot, been staring at that one line for 15 minutes trying to see the mistake! that explains it. thanks for your help MrAdam Link to comment https://forums.phpfreaks.com/topic/171777-solved-returning-all-records-made-within-the-last-24hrs/#findComment-905801 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.