shocker-z Posted April 10, 2006 Share Posted April 10, 2006 please help me i've gone brain dead!Whats the SQL statement to get records from past 5 minutes from table, im using a datetime field..I know it's easy but i had a search and can't find it and in 2 days of work i've locked myself out of 2 booking programs 5 times! think im ill! lol i even wrote the passwords down and put them next to the wrong accounts..Thanks in advance :) Quote Link to comment https://forums.phpfreaks.com/topic/7044-last-5minutes/ Share on other sites More sharing options...
ober Posted April 10, 2006 Share Posted April 10, 2006 [code]SELECT * FROM tablexyz WHERE date_time_field < '" . date("whatever_format", strtotime("5 minutes ago")) . "' [/code] Quote Link to comment https://forums.phpfreaks.com/topic/7044-last-5minutes/#findComment-25614 Share on other sites More sharing options...
shocker-z Posted April 11, 2006 Author Share Posted April 11, 2006 $guests=mysql_query("SELECT count(*) AS `guest_count` FROM hits WHERE member = 'guest' AND `page` = '$page_name' AND datetime < '" . date("Y-m-d H:i:s", strtotime("5 minutes ago"))."'") or die (mysql_error());i also tryed date("YmdHis", How come that's still showing all records? I think that i have got the wrong idea with the date("Y-m-d H:i:s", bit?This is how the datetime stamp is in my tabel: 2006-04-11 09:38:00 Quote Link to comment https://forums.phpfreaks.com/topic/7044-last-5minutes/#findComment-25770 Share on other sites More sharing options...
shocker-z Posted April 11, 2006 Author Share Posted April 11, 2006 **SOLVED**$guests=mysql_query("SELECT count(*) AS `guest_count` FROM hits WHERE member = 'guest' AND `page` = '$page_name' AND DATE_SUB(NOW(), INTERVAL 5 MINUTE) < datetime") or die (mysql_error());working a treat :) Quote Link to comment https://forums.phpfreaks.com/topic/7044-last-5minutes/#findComment-25813 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.