Re: if else query help - Mailing list pgsql-sql

From Jean-Christophe Boggio
Subject Re: if else query help
Date
Msg-id 6812102772.20001012165653@thefreecat.org
Whole thread Raw
In response to if else query help  ("Brian C. Doyle" <bcdoyle@mindspring.com>)
Responses Re: if else query help
List pgsql-sql
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 t2where t1.itemid=t2.itemid     -- to link
thetables  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




pgsql-sql by date:

Previous
From: Mark Volpe
Date:
Subject: Re: dynamic object creation
Next
From: Josh Berkus
Date:
Subject: Re: if else query help