X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 1E2449DC9CF for ; Wed, 1 Mar 2006 13:05:48 -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 36231-03 for ; Wed, 1 Mar 2006 13:05:46 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id 8BDFD9DC9AF for ; Wed, 1 Mar 2006 13:05:45 -0400 (AST) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id C273C30972; Wed, 1 Mar 2006 18:05:44 +0100 (MET) From: Mark Dilger X-Newsgroups: pgsql.hackers Subject: Re: [SQL] Interval subtracting Date: Wed, 01 Mar 2006 09:05:09 -0800 Organization: Hub.Org Networking Services Lines: 29 Message-ID: <4405D445.4000200@markdilger.com> References: <200602181444.06009.milorad.poluga@cores.co.yu> <43F72E27.2060408@radev.net> <200602181536.20605.milorad.poluga@cores.co.yu> <43F7330E.1060907@radev.net> <20402.1140287414@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@news.hub.org To: Tom Lane User-Agent: Mozilla Thunderbird 1.0 (X11/20050130) X-Accept-Language: en-us, en In-Reply-To: <20402.1140287414@sss.pgh.pa.us> X-Enigmail-Version: 0.89.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime To: pgsql-hackers@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.105 required=5 tests=[AWL=0.105] X-Spam-Score: 0.105 X-Spam-Level: X-Archive-Number: 200603/24 X-Sequence-Number: 80422 Tom Lane wrote: > "Milen A. Radev" writes: > >>Milorad Poluga написа: >> >>>>SELECT '10 years 1 mons 1 days'::interval - '9 years 10 mons 15 days'::interval >>>>?column? >>>>--------------- >>>>3 mons -14 days >>>> >>>>Why not '2 mons 16 days' ? > > >>Please read the last paragraph in section 8.5.1.4 of the manual >>(http://www.postgresql.org/docs/8.1/static/datatype-datetime.html#AEN4775) >>. It mentions the functions named "justify_days" and "justify_hours" >>that could do what you need. > > > justify_days doesn't currently do anything with this result --- it > thinks its charter is only to reduce day components that are >= 30 days. > However, I think a good case could be made that it should normalize > negative days too; that is, the invariant on its result should be > 0 <= days < 30, not merely days < 30. Similarly for justify_hours. > Comments anyone? Patch anyone? Sure, if nobody objects to this change I can write the patch. mark