X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1E680475CBC for ; Wed, 26 Mar 2003 03:34:07 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id 79EFB474E44 for ; Wed, 26 Mar 2003 03:34:01 -0500 (EST) Received: from klaster.net (pq97.krakow.cvx.ppp.tpnet.pl [213.76.41.97]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 77CD36A21E; Wed, 26 Mar 2003 09:33:48 +0100 (CET) Message-ID: <3E81620E.20604@klaster.net> Date: Wed, 26 Mar 2003 09:17:18 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; pl-PL; rv:1.3) Gecko/20030312 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: Bruno Wolff III Cc: pgsql-sql@postgresql.org Subject: Re: Does anyone use TO_CHAR(INTERVAL)? References: <200303250931.27351.josh@agliodbs.com> <3E80AD07.5000005@klaster.net> <20030326044356.GA18525@wolff.to> In-Reply-To: <20030326044356.GA18525@wolff.to> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-31.1 required=5.0 tests=BAYES_01,IN_REP_TO,QUOTED_EMAIL_TEXT,RCVD_IN_RFCI, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MOZILLA_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/574 X-Sequence-Number: 12612 Uz.ytkownik Bruno Wolff III napisa?: > On Tue, Mar 25, 2003 at 20:24:55 +0100, > Tomasz Myrta wrote: > >>Uz.ytkownik Josh Berkus napisa?: >> >>It looks it could be useful to display how much time is left for >>scheduling cases, but as I wrote few threads ago - displaying intervals >>longer than one month is useless without specific date. > > > That isn't true. Intervals have two parts. One is time difference in > fixed time and the other is a difference in months. You could display > both parts when they are both nonzero. > > I haven't found the documenation too specific on which part gets added > first (and this does make a difference in some cases). It looks like you are right: SELECT cast('300 days' as interval)+cast('1 month' as interval);; ?column? ---------------- 1 mon 300 days SELECT to_char(cast('300 days' as interval)+cast('1 month' as interval),'DDD');; to_char --------- 300 (1 row) SELECT to_char('2002-12-31'::timestamp -'2002-01-01'::timestamp,'YYYY-MM-DD');; to_char ------------- 0000-00-36 (1 row) Thanks for noticing this, these results are really strange for me. I should remember NOT to use months when working with intervals. It looks like intervals contain 2 totally independent values inside. I have one more question to this thread - Does anyone use intervals month value? Tomasz