Re: Date/Time Query Help

From: Date: Tue, 24 Jul 2001 18:58:09 +0000
Subject: Re: Date/Time Query Help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-59400@lists.php.net to get a copy of this message
On Tue, 24 Jul 2001 15:09:14 -0400, Rshrout@krauss-maffeicorp.com (Ryan Shrout) wrote: >I need a MySQL query that will select all the entries in it made within the >last hour. > >I tried this, but it is not working correctly, what am I doing wrong? > >SELECT * > FROM session > > WHERE (session.Date > DATE_SUB(NOW(), INTERVAL 1 HOUR)) Now() will return the current time. by definition, at the time it's running, there will be zero or almost zero (depends on how fast the query runs... someone might insert a row between when the now() gets executed and when the query ends) rows. you are basically asking for rows that were inserted from now up to one hour in the future. those rows aren't there yet. try testing for less than.

« previous php.general (#59400) next »