Received: from miaou.thefreecat.org (IDENT:postfix@[213.11.8.225]) by hub.org (8.10.1/8.10.1) with ESMTP id e9CErbr49428 for ; Thu, 12 Oct 2000 10:53:37 -0400 (EDT) Received: from bast.thefreecat.local (bast.thefreecat.local [192.168.0.2]) by miaou.thefreecat.org (Postfix) with ESMTP id 5404B9301C; Thu, 12 Oct 2000 16:53:34 +0200 (CEST) Date: Thu, 12 Oct 2000 16:56:53 +0200 From: Jean-Christophe Boggio X-Mailer: The Bat! (v1.46d) Personal Reply-To: Jean-Christophe Boggio X-Priority: 3 (Normal) Message-ID: <6812102772.20001012165653@thefreecat.org> To: "Brian C. Doyle" Cc: pgsql-sql@postgresql.org Subject: Re: if else query help In-reply-To: <5.0.0.25.2.20001012094914.081abeb0@pop.mindspring.com> References: <5.0.0.25.2.20001012094914.081abeb0@pop.mindspring.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200010/115 X-Sequence-Number: 1777 hi Brian, BCD> I need to write a query that will pull information from table2 if BCD> information in table1 is older then xdate. BCD> My laymen example: BCD> SELECT table2.date, count(table2.name) as count BCD> WHERE table1.startdate > 2 weeks BCD> AND table2.submitdate > 2 weeks BCD> ; BCD> So i Guess my real questions is how do I determine the age of an entry to BCD> another table? Try this : Select table2.date,count(table2.name) as count from table1 as t1, table2 as t2 where t1.itemid=t2.itemid -- to link the tables and t1.startdate>now()-14 and t2.submitdate>now()-14; Someone corrects me if I'm wrong, I come from the Oracle world... Dates (or I should say TimeStamps) are stored as floating point values : the integer part is the number of days since a certain date (epoch or 01/01/1970 on unix-based databases) and the fractionnal part is the portion of the day (although I don't know --yet-- how to convert date2-date1 to an integer, trunc does not work). HTH -- Jean-Christophe Boggio cat@thefreecat.org Independant Consultant and Developer Delphi, Linux, Oracle, Perl