Forum Moderators: coopster

Message Too Old, No Replies

Try this for getting results in last hour in a database mysql table

         

usman

6:55 pm on Sep 22, 2009 (gmt 0)

10+ Year Member



datecreated >= DATE_SUB(NOW( ),INTERVAL 1 HOUR)

whoisgregg

10:50 pm on Sep 22, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, usman!

Thanks for posting! That code looks perfect to me, are you having trouble with it or just posting for others with the same issue?

Incidentally (since we're in the PHP forum) you can also generate the date string to send to mysql with something like:

$sql = "SELECT * FROM `table` WHERE `created` >= '".date("Y-m-d H:i:s", strtotime("-1 hour"))."'";

usman

11:06 pm on Sep 22, 2009 (gmt 0)

10+ Year Member



Thanks, i was trying to reply to some earlier post by some other user but that post was quite old so there was no reply option and i had to create this new post.

whoisgregg

2:06 pm on Sep 23, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That's great! Hope to see you around the forum more often. :)