Log in

View Full Version : Selecting a time range



Grant Holmes
01-03-2008, 08:46 PM
Hi gang. Ima Newbie and stuck. I'm trying to display active records in a table on my web page. However, to minimize maintenance, I only want to display records that are up to 48 hours old at any point. Here's my code so far:


$query="SELECT * from birthdays where Active='1' AND Event='request' AND hour(DateEntered)< 48";

Where "Active" is a flag at 1/0..."Event" is populated and "DateEntered" is a system TimeStamp of the record creation.

I have 11 Active records total that are active and 5 that are active AND 48 hours old, or less, so my page should return 5 records. It's returning all 11.

Any help?

Grant Holmes
01-03-2008, 09:12 PM
$query="SELECT * from birthdays where Active='1' AND Event='request' AND DateEntered > (NOW()-86400*2)";

Was the answer. Got it fixed. Thanks all