Received: from netmeme.org ([204.144.237.82]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id eAHMZUs72667 for ; Fri, 17 Nov 2000 17:35:30 -0500 (EST) (envelope-from bryan_lists@netmeme.org) Received: from workstation (workstation.netmeme.org [204.144.237.84]) by netmeme.org (8.9.3/8.9.3) with SMTP id PAA08988 for ; Fri, 17 Nov 2000 15:31:03 -0700 Message-ID: <02ba01c050e6$72f876c0$54ed90cc@netmeme.org> From: "Bryan \(Mailing Lists\)" To: References: Subject: Date arithmatic question Date: Fri, 17 Nov 2000 15:33:46 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Archive-Number: 200011/551 X-Sequence-Number: 675 I have a table "t" with a timestamp column "s". I am trying to issue a query to find all rows where s is exactly some number of days old (rounded off). I have tried this: select * from t where date_part('day', age('now', s)) = ? But this only looks at the day of the month; e.g. if my parameter is "5", then it will return all rows that are 5 days old, as well as 1 month 5 days, as well as 2 months 5 days, etc. I have also tried this: select * from t where date_part('day', age('now', s)) = ? and date_part('month', age('now', status_last_update)) = 0 But this restricts my parameter to 30 days or less; greater than 30 days and the query doesn't return anything. What is the correct way to express this? Thank you, Bryan