$SQL = "select * from datbase where (TO_DAYS(NOW())-TO_DAYS(dateadded)<1)"; # look for records less than 1 day old &Do_SQL; while ($pointer = $sth->fetchrow_hashref) { $total = $pointer->{'total'}; if ($total eq "3") { $revenue = 30; } elsif ($total eq "6") { $revenue = 48; } elsif ($total eq "10") { $revenue = 50; } } $sth->finish();