Received: from bjke.com (firewall-user@ganymede.bjke.com [144.210.8.38]) by hub.org (8.9.3/8.9.3) with ESMTP id TAA08756 for ; Mon, 26 Jul 1999 19:16:30 -0400 (EDT) (envelope-from djackson@cpsgroup.com) Received: by bjke.com; id SAA09309; Mon, 26 Jul 1999 18:16:29 -0500 (CDT) Received: from unknown(144.210.12.10) by gauntlet.bjke.com via smap (4.1) id xma009299; Mon, 26 Jul 99 18:16:24 -0500 Received: by cpsmail with Internet Mail Service (5.5.2448.0) id <3Y5R553R>; Mon, 26 Jul 1999 18:16:16 -0500 Message-ID: From: "Jackson, DeJuan" To: David Rose , pgsql-sql@postgreSQL.org Subject: RE: [SQL] timespan arithmetic Date: Mon, 26 Jul 1999 18:16:09 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2448.0) Content-Type: text/plain I'm not certain this will work, but try: SELECT * FROM table WHERE loaded_time::datetime >= now()::datetime - '1 days'::timespan ORDER BY loaded_time DESC; > -----Original Message----- > From: David Rose [SMTP:David.R.Rose@disney.com] > Sent: Monday, July 26, 1999 6:01 PM > To: pgsql-sql@postgreSQL.org > Subject: [SQL] timespan arithmetic > > Hello. > > I recently posted this question on pgsql-novice and received no > answer. Undaunted, I'm trying again on pgsql-sql. Perhaps someone > knows at least where to start looking for an answer to this problem. > It's not in the FAQ, and I couldn't find an answer in the mailing list > archives. > > I have a table that includes a column of type timestamp. I'd like to > formulate a query that returns, say, all rows no more than 24 hours > old, based on the timestamp. Trial and error got me this far (and a > perusal of the mailing list archives confirmed it): > > SELECT * FROM table > WHERE loaded_time >= 'now'::timestamp - '1 days'::timespan > ORDER BY loaded_time DESC; > > This works fine in PostgreSQL 6.4.2. However, another user of my > software, who has PostgreSQL 6.3.2, reports that he gets the following > error message: > > ERROR: There is no operator '-' for types 'timestamp' and 'timespan' > You will either have to retype this query using an explicit cast, or you > will have to define the operator using CREATE OPERATOR > > > So. Is there a correct solution to this problem that works for all > versions of PostgreSQL--or at least, PostgreSQL versions 6.3.2 and > higher? Barring that, is there at least a solution at all for 6.3.2, > which may or may not be different from the solution for 6.4.2 and > higher? > > Many thanks. > > David >