Re: Finding rows older than one hour

From: Date: Thu, 29 Jun 2000 00:38:05 +0000
Subject: Re: Finding rows older than one hour
Groups: php.db 
Request: Send a blank email to php-db+get-721@lists.php.net to get a copy of this message
Addressed to: =?iso-8859-1?q?Maxwell=20Hung?= <maxwell_hung@yahoo.com> php-db@lists.php.net ** Reply to note from =?iso-8859-1?q?Maxwell=20Hung?= <maxwell_hung@yahoo.com> Wed, 28 Jun 2000 03:36:42 -0700 (PDT) > > I am getting this error for that select > > MySQL said: parse error near '(NOW(), INTERVAL 1 HOUR)' at line 1 I > am using mysql ver 3.21.29 Thanks Your MySQL may be too old. I'm starting to get nervous about how old mine is, and I'm using 3.22.25. From the MySQL interpreter, this works: mysql> SELECT SUBDATE( NOW(), INTERVAL 1 HOUR ); +-----------------------------------+ | subdate( now(), interval 1 hour ) | +-----------------------------------+ | 2000-06-28 16:26:27 | +-----------------------------------+ 1 row in set (0.00 sec) How about for you? If it does, look at the entire query, or send it to me. If it does not work, you may have to format the data in PHP like this: $OldTime = strftime( "%Y-%m-%d %H:%M:%S", time() - 3600 ); WHERE your_timestamp < '$OldTime' ( 3600 seconds = 1 hour.) > > --- php3@developersdesk.com wrote: > Addressed to: > =?iso-8859-1?q?Maxwell=20Hung?= > > <maxwell_hung@yahoo.com> > > php-db@lists.php.net > > > > ** Reply to note from > > =?iso-8859-1?q?Maxwell=20Hung?= > > <maxwell_hung@yahoo.com> Wed, 28 Jun 2000 02:21:09 > > -0700 (PDT) > > > > > > I have a column in a table that is a timestamp > > field. How can I find > > > columns that are older than one hour? I've looked > > in the manuals but > > > most of the examples use date/time fields. > > > > > > > A timestamp field is just a datetime field with the > > additional property > > that the first one in your table is automagically > > updated each time any > > other fields in your row are updated. > > > > > > so... > > > > > > WHERE your_timestamp < SUBDATE( NOW(), INTERVAL 1 > > HOUR ) > > > > > > should work. (At least for MySQL.) > > > > > > > > > > Rick Widmer > > Internet Marketing Specialists > > www.developersdesk.com > > > __________________________________________________ Do You Yahoo!? Get > Yahoo! Mail - Free email you can access from anywhere! > http://mail.yahoo.com/ > Rick Widmer Internet Marketing Specialists www.developersdesk.com

« previous php.db (#721) next »