X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id ABE709DC9E7 for ; Sat, 18 Feb 2006 10:35:47 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 70896-03 for ; Sat, 18 Feb 2006 10:35:51 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.cores.co.yu (cores-2.yubc.net [213.184.101.2]) by postgresql.org (Postfix) with SMTP id 0811F9DC949 for ; Sat, 18 Feb 2006 10:35:44 -0400 (AST) Received: (qmail 5718 invoked by uid 1013); 18 Feb 2006 14:45:24 -0000 Received: from milorad.poluga@cores.co.yu by mail by uid 1010 with qmail-scanner-1.22-st-qms (clamdscan: 0.74. spamassassin: 2.63. Clear:RC:1(10.0.1.253):. Processed in 0.237242 secs); 18 Feb 2006 14:45:24 -0000 X-Antivirus-CORESINC-Mail-From: milorad.poluga@cores.co.yu via mail X-Antivirus-CORESINC: 1.22-st-qms (Clear:RC:1(10.0.1.253):. Processed in 0.237242 secs Process 5711) Received: from unknown (HELO poluga.linsoft.co.yu) (10.0.1.253) by mail.cores.co.yu with SMTP; 18 Feb 2006 14:45:24 -0000 From: Milorad Poluga Organization: CORES To: pgsql-sql@postgresql.org Subject: Re: Interval subtracting Date: Sat, 18 Feb 2006 15:36:20 +0100 User-Agent: KMail/1.6.1 Cc: "Milen A. Radev" References: <200602181444.06009.milorad.poluga@cores.co.yu> <43F72E27.2060408@radev.net> In-Reply-To: <43F72E27.2060408@radev.net> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <200602181536.20605.milorad.poluga@cores.co.yu> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] X-Spam-Score: 0.12 X-Spam-Level: X-Archive-Number: 200602/236 X-Sequence-Number: 24246 On Saturday 18 February 2006 15:24, Milen A. Radev wrote: > Milorad Poluga =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0: > > Hi all, > >=20 > > Is there something incorrect in the above query ?=20 > > SELECT '10 years 1 mons 1 days'::interval - '9 years 10 mons 15 days'::= interval > >=20 > > ?column? =20 > > ---------------=20 > > 3 mons -14 days=20 > >=20 > > Why not '2 mons 16 days' ?=20 > >=20 > > /version =3D PostgreSQL 8.0.4 on i686-pc-linux-gnu, compiled by GCC gc= c (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3) / >=20 >=20 > How many days are there in a month? >=20 I beleive that a month is calculated on the 30-days base. One way to solve this problem is to use a neutal date element and make time= stamps : SELECT age(('1990-01-01'::date + '10 years 1 mons 1 days'::interval)::times= tamp , ('1990-01-01'::date + '9 years 10 mons 15 days'::interval)::timestamp) age =20 --------------=20 2 mons 16 days=20 Regards,=20 Milorad Poluga =2D-------------------------------------- milorad.poluga@cores.co.yu =2D--------------------------------------