pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomasz Myrta <jasiek@klaster.net>
To: Peter Childs <blue.dragon@blueyonder.co.uk>
Cc: pgsql-sql@postgresql.org
Subject: Re: Does anyone use TO_CHAR(INTERVAL)?
Date: Wed, 26 Mar 2003 11:05:23 +0100
Message-ID: <3E817B63.2040006@klaster.net> (raw)
In-Reply-To: <Pine.LNX.4.44.0303260929090.5091-100000@RedDragon.Childs>
References: <Pine.LNX.4.44.0303260929090.5091-100000@RedDragon.Childs>

Uz.ytkownik Peter Childs napisa?:
> On Wed, 26 Mar 2003, Tomasz Myrta wrote:
> 
> 
>>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?
> 
> 
> 	Since all months are not equal in length how do else do you come 
> 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 
> because 1 month <> 1 month hense.
> 
> select (cast('2-2-2003' as date) + cast('1 month' as interval)) - 
> cast('2-2-2003' as date);
>  ?column?
> ----------
>  28 days
> (1 row)
> 
> but if all you say is 1 month from now how many days you month you mean 
> will mean a different number of days. Oh one more good one is....
> 
> select cast('1 year' as interval) - cast('365 days' as interval);
>      ?column?
> ------------------
>  1 year -365 days
> (1 row)
> 
> 	It would seam that a year is 12 months but not 365 days which 
> while this is true (due to leap years) most people would never think like 
> that. Its seams that postgres will not tell you how many days there are in 
> a year but this seams even more stupid 
> 
> select cast('1 month' as interval)/2 * 2;
>  ?column?
> ----------
>  360 days
> (1 row)
> 
> oh and just when you thought somthing was really straght forward you 
> get...
> 
> select cast('1 year' as interval)/24 * 24;
>  ?column?
> ----------
>  360 days
> (1 row)
> 
> 	This reminds me of a calculator that comes with MS Windows....
> 	How ever the implementation in postgres is the best I've sean so 
> long as you don't do anything stupid!
> 
> Peter Childs

I already know all of these things (look at thread "Formatting 
intervals" dated on 2003-03-17). I was just thinking about intervals 
idea. Keeping time inside interval is good. Keeping months inside 
interval also looks good, but keeping both of them doesn't make sense. 
It is impossible to use these fields together without referring them to 
some real date.

Tomasz Myrta




view thread (8+ messages)  latest in thread

Message-ID: <3E817B63.2040006@klaster.net>
Permalink:  ../3E817B63.2040006@klaster.net/
Also on:    postgresql.org/message-id/3E817B63.2040006@klaster.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jasiek@klaster.net, blue.dragon@blueyonder.co.uk
  Subject: Re: Does anyone use TO_CHAR(INTERVAL)?
  In-Reply-To: <3E817B63.2040006@klaster.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox