X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E3024475CBC for ; Wed, 26 Mar 2003 05:38:00 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id 5B5F5474E44 for ; Wed, 26 Mar 2003 05:37:27 -0500 (EST) Received: from klaster.net (ph133.krakow.cvx.ppp.tpnet.pl [217.99.208.133]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id A63166A241; Wed, 26 Mar 2003 11:37:16 +0100 (CET) Message-ID: <3E817B63.2040006@klaster.net> Date: Wed, 26 Mar 2003 11:05:23 +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: Peter Childs Cc: pgsql-sql@postgresql.org Subject: Re: Does anyone use TO_CHAR(INTERVAL)? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-38.8 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, 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/579 X-Sequence-Number: 12617 Uz.ytkownik Peter Childs napisa?: > On Wed, 26 Mar 2003, Tomasz Myrta wrote: >=20 >=20 >>Thanks for noticing this, these results are really strange for me. >>I should remember NOT to use months when working with intervals. It=20 >>looks like intervals contain 2 totally independent values inside. >> >>I have one more question to this thread - Does anyone use intervals=20 >>month value? >=20 >=20 > Since all months are not equal in length how do else do you come=20 > up with an interval that is 1 month since us humans like to use months. > As you note Postgres trys to ovide using Months if at all possible=20 > because 1 month <> 1 month hense. >=20 > select (cast('2-2-2003' as date) + cast('1 month' as interval)) -=20 > cast('2-2-2003' as date); > ?column? > ---------- > 28 days > (1 row) >=20 > but if all you say is 1 month from now how many days you month you mean= =20 > will mean a different number of days. Oh one more good one is.... >=20 > select cast('1 year' as interval) - cast('365 days' as interval); > ?column? > ------------------ > 1 year -365 days > (1 row) >=20 > It would seam that a year is 12 months but not 365 days which=20 > while this is true (due to leap years) most people would never think like= =20 > that. Its seams that postgres will not tell you how many days there are i= n=20 > a year but this seams even more stupid=20 >=20 > select cast('1 month' as interval)/2 * 2; > ?column? > ---------- > 360 days > (1 row) >=20 > oh and just when you thought somthing was really straght forward you=20 > get... >=20 > select cast('1 year' as interval)/24 * 24; > ?column? > ---------- > 360 days > (1 row) >=20 > This reminds me of a calculator that comes with MS Windows.... > How ever the implementation in postgres is the best I've sean so=20 > long as you don't do anything stupid! >=20 > Peter Childs I already know all of these things (look at thread "Formatting=20 intervals" dated on 2003-03-17). I was just thinking about intervals=20 idea. Keeping time inside interval is good. Keeping months inside=20 interval also looks good, but keeping both of them doesn't make sense.=20 It is impossible to use these fields together without referring them to=20 some real date. Tomasz Myrta