Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 060BD2E003A for ; Tue, 13 May 2008 03:57:00 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 47067-02 for ; Tue, 13 May 2008 03:56:55 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smadev.internal.net (host3.dynacom.ondsl.gr [62.103.35.211]) by developer.postgresql.org (Postfix) with ESMTP id E7DAA2E0039 for ; Tue, 13 May 2008 03:56:56 -0300 (ADT) Received: from smadev.internal.net (localhost [127.0.0.1]) by smadev.internal.net (8.14.2/8.14.2) with ESMTP id m4D6urqp097501; Tue, 13 May 2008 09:56:53 +0300 (EEST) (envelope-from achill@matrix.gatewaynet.com) Received: from localhost (localhost [[UNIX: localhost]]) by smadev.internal.net (8.14.2/8.14.2/Submit) id m4D6uqYA097500; Tue, 13 May 2008 09:56:52 +0300 (EEST) (envelope-from achill@matrix.gatewaynet.com) From: Achilleas Mantzios Organization: Dynacom Tankers Mgmt To: pgsql-admin@postgresql.org Subject: Re: how to get a number of seconds in some interval ? Date: Tue, 13 May 2008 09:56:50 +0300 User-Agent: KMail/1.9.7 Cc: Tom Lane , Julius Tuskenis References: <482849B0.6050103@nsoft.lt> <200805121801.35101.achill@matrix.gatewaynet.com> <20080.1210604951@sss.pgh.pa.us> In-Reply-To: <20080.1210604951@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200805130956.51872.achill@matrix.gatewaynet.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/101 X-Sequence-Number: 29185 =CE=A3=CF=84=CE=B9=CF=82 Monday 12 May 2008 18:09:11 =CE=BF/=CE=B7 Tom Lane= =CE=AD=CE=B3=CF=81=CE=B1=CF=88=CE=B5: > Achilleas Mantzios writes: > > =CE=A3=CF=84=CE=B9=CF=82 Monday 12 May 2008 17:32:39 =CE=BF/=CE=B7 Juli= us Tuskenis =CE=AD=CE=B3=CF=81=CE=B1=CF=88=CE=B5: > >> do you know why division of intervals was not implemented? As I see it= -=20 > >> there should be an easy way to do so. '1 hour 30 minutes' / '1 hour' = =3D=20 > >> 1.5 .... Seems straight forward... > >>=20 > > No idea why. However as you pose it,it makes sense. >=20 > No, it doesn't really, because intervals contain multiple components. > What would you define as the result of > '1 month 1 hour' / '1 day' > bearing in mind that the number of days per month is not fixed, and > neither is the number of hours per day? >=20 SELECT extract(epoch from '1 month'::interval)/(60*60*24) as "Days in 1 mon= th interval"; Days in 1 month interval =2D------------------------- 30 (1 row) So it seems that the arbitary assumption of (1 month=3D30 days, and 1 day = =3D 24 hours) has already been made=20 in the extract function. > You can derive a number if you're willing to make arbitrary assumptions > about the relationships of the different units (as indeed extract(epoch) > does), but hard-wiring such assumptions into a basic arithmetic operator > doesn't seem like a good idea to me. >=20 > regards, tom lane >=20 =2D-=20 Achilleas Mantzios