Re: Timestamp/Interval proposals: Part 2

From: Hannu Krosing <hannu(at)tm(dot)ee>
To: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
Cc: Fduch the Pravking <fduch(at)antar(dot)bryansk(dot)ru>, Thomas Lockhart <lockhart(at)fourpalms(dot)org>, josh(at)agliodbs(dot)com, hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Timestamp/Interval proposals: Part 2
Date: 2002-06-11 10:52:41
Message-ID: 1023792761.6942.59.camel@taru.tm.ee
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 2002-06-11 at 11:31, Karel Zak wrote:
> On Tue, Jun 11, 2002 at 12:37:09PM +0400, Fduch the Pravking wrote:
>
> > And 'DD' is defined as in range 1..31...
> > What if I try to select '100 days'?
> >
> > fduch=> SELECT to_char('100days'::interval, 'YYYY-MM-DD HH24:MI:SS');
> > to_char
> > ---------------------
> > 0000-00-10 00:00:00
>
> I already said it. The to_char() is 'tm' struct interpreter and use
> standard internal PG routines for interval to 'tm' conversion.

The point is it should _not_ do that for interval.

It does not convert to 'tm' for other types:

hannu=# select to_char(3.1415927,'0009D9');
to_char
---------
0003.1
(1 row)

also, afaik there is no conversion of interval to datetime in
postgresql:

hannu=# select '25mon37d1s'::interval::timestamp;
ERROR: Cannot cast type 'interval' to 'timestamp with time zone'

> We can
> talk about why 100days is converted to '10' days and months aren't
> used. I agree this example seems strange. Thomas?

You can't convert days to months as there is no universal month length.

this is the current (correct) behaviour:

hannu=# select '25mon37d1s'::interval;
interval
--------------------------------
2 years 1 mon 37 days 00:00:01
(1 row)

------------------
Hannu

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message NunoACHenriques 2002-06-11 10:53:26 Re: tuplesort: unexpected end of data
Previous Message Lee Kindness 2002-06-11 10:51:50 Re: Bug #640: ECPG: inserting float numbers