Jump to content


Photo

last 5minutes


  • Please log in to reply
3 replies to this topic

#1 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 10 April 2006 - 05:02 PM

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 :)
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 10 April 2006 - 07:49 PM

SELECT * FROM tablexyz WHERE date_time_field < '" . date("whatever_format", strtotime("5 minutes ago")) . "'

Info: PHP Manual


#3 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 11 April 2006 - 08:36 AM

$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
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#4 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 11 April 2006 - 12:01 PM

**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 :)
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users