X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C046256464 for ; Mon, 21 Mar 2005 11:00:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 42594-06 for ; Mon, 21 Mar 2005 11:00:16 +0000 (GMT) Received: from kallisto.it-raum.ch (unknown [213.189.139.249]) by svr1.postgresql.org (Postfix) with ESMTP id 2A18056463 for ; Mon, 21 Mar 2005 11:00:10 +0000 (GMT) Received: from nimas.it-raum.ch (unknown [192.168.10.1]) by kallisto.it-raum.ch (Postfix) with ESMTP id 3B3C556A6F; Mon, 21 Mar 2005 13:49:44 +0100 (CET) Subject: Re: Your question about date From: =?ISO-8859-1?Q?B=E9atrice?= Yueksel To: Christoph Haller Cc: Octavio Alvarez , pgsql-sql@postgresql.org In-Reply-To: <423E99E2.7D428966@rodos.fzk.de> References: <423E99E2.7D428966@rodos.fzk.de> Content-Type: text/plain; charset=UTF-8 Date: Mon, 21 Mar 2005 11:59:18 +0100 Message-Id: <1111402758.5174.22.camel@nimas.it-raum.ch> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 (2.0.2-3) Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200503/281 X-Sequence-Number: 20760 Dear Christoph, perhaps you could try something like this example. Regards, Béatrice The table: ---------- # select * from test; date ------------ 2005-02-02 2005-03-05 2005-04-07 2005-05-02 (4 rows) The query ---------- SELECT (( select test1.date from test test1 where test1.date > test.date limit 1) - test.date ) AS result from test; t1.date > RESULT: ------- result -------- 31 33 25 Am Montag, den 21.03.2005, 10:54 +0100 schrieb Christoph Haller: > Octavio Alvarez wrote: > > > > Sorry, I tried to make my subject as good as possible. > > Ahem, what subject? > > > > I have a table where I store the dates in which I take out of my inventory > > (like "installation dates") > > > > table > > --------------- > > row_id SERIAL > > date DATE > > fk_item INTEGER > > > > and that's pretty much it. > > > > I want to have a query returning how long have been certain items lasting. > > > > Say I have: > > > > SELCT date FROM table WHERE fk_item = "INKJET_INK-BW" > > > > date > > ------------- > > 2005-02-02 > > 2005-03-05 > > 2005-04-07 > > 2005-05-02 > > > > I need something to calculate the intervals between those dates, like this: > > > > intervals (in days) > > -------------------- > > 31 > > 34 > > 25 > > > > So I can get the stddev and stuff from the "duration" of the items. > > > > I've been having a hard time with it. I'm trying NOT to program new > > functions. > > I cannot see how this could be achieved without the use of a function. > But if there is a way after all, I would be interested in learning it. > > > > Any help will be appreciated. > > > > --Octavio > > -- > > Regards, Christoph > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly --