RE: [PHP] Re: Date/Time Query Help

From: Date: Tue, 24 Jul 2001 19:23:10 +0000
Subject: RE: [PHP] Re: Date/Time Query Help
Groups: php.general 
Request: Send a blank email to php-general+get-59403@lists.php.net to get a copy of this message
Think of it this way: WHERE session.Date > DATE_SUB(NOW(), INTERVAL 1 HOUR) is equal to: WHERE 2001-07-24 15:03:24 > SUBTRACTION( 2001-07-24 15:30:21, 00:01:00) = WHERE 2001-07-24 15:03:24 > 2001-07-24 14:30:21 That seems right now, but it doesn't work Ryan -----Original Message----- From: bopolissimus@sni.ph [mailto:bopolissimus@sni.ph] Sent: Tuesday, July 24, 2001 2:58 PM To: php-general@lists.php.net Subject: [PHP] Re: Date/Time Query Help 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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#59403) next »