Re: Timestamp/Interval proposals: Part 2

From: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
To: Hannu Krosing <hannu(at)tm(dot)ee>
Cc: 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 09:21:40
Message-ID: 20020611112140.B19916@zf.jcu.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jun 11, 2002 at 11:16:13AM +0200, Hannu Krosing wrote:
> On Tue, 2002-06-11 at 09:34, Karel Zak wrote:

> > I think, we can keep this behaviour for to_char(), the good thing
> > is that you can formatting interval to strings that seems like
> > standard time (15:10:33), etc.
>
> But interval _is_ _not_ point-in-time, it is a time_span_ .
>
> It can be either good if it gives the results you want or bad if it does
> give wrong results like returning 03:10:33 for the above
>
> I would suggest that a separate to_char function would be written that
> would be _specific_to_interval_ datatype - so wheb i do
>
> to_char('33s 15h 10m'::interval, 'SS') I will get the actual length of
>
> interval in seconds, 15*3600+10*60+33 = 54633s and not just the seconds part (33)
>
> whereas to_char('33s 15h 10m'::interval, 'MI SS') would give
>
> 15*60+10=910 min 33 sec ('910 33')

Well, If the to_char() for interval will output result that you want,
how can I output '15:10:33'?

For this I want two direffent function or anothers format marks for
to_char() like

to_char('33s 15h 10m'::interval, '#MI #SS');
---
'910 33'

but for "standard" marks (that now works like docs describe :-) will output
MI in 0..59 range.

to_char('33s 15h 10m'::interval, 'MI:SS');
---
'10:33'

IMHO it's acceptable. I don't want close the way for output formatting
in "standard" date/time ranges. We can support _both_ ways. Or not?

Thomas, you are quiet? :-)

Karel

PS. the PostgreSQL converting intervals to "standard" format too:

test=# select '33h 15m'::interval - '10h 2m 3s'::interval ;
?column?
----------
23:12:57
(1 row)

test=# select '45h 15m'::interval - '10h 2m 3s'::interval ;
?column?
----------------
1 day 11:12:57

(hmm.. I unsure if this is really released 7.2, I maybe have
some pre-7.2 version now. Is this 7.2 behaviuor?)

--
Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
http://home.zf.jcu.cz/~zakkr/

C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marc G. Fournier 2002-06-11 09:30:39 Re: Project scheduling issues (was Re: Per tuple overhead,
Previous Message Hannu Krosing 2002-06-11 09:16:13 Re: Timestamp/Interval proposals: Part 2