pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedto_char(interval) ?
3+ messages / 2 participants
[nested] [flat]
* to_char(interval) ?
@ 2005-04-24 20:08 Theodore Petrosky <tedpet5@yahoo.com>
0 siblings, 1 reply; 3+ messages in thread
From: Theodore Petrosky @ 2005-04-24 20:08 UTC (permalink / raw)
To: pgsql-sql
how do I get an interval '1 day 1 hour' to display as
'25 hours'. I am hunting in the docs (and googling)
and either I am blind or I need a special function?
Is there an easy way?
Ted
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: to_char(interval) ?
@ 2005-04-25 04:23 Bruno Wolff III <bruno@wolff.to>
parent: Theodore Petrosky <tedpet5@yahoo.com>
0 siblings, 0 replies; 3+ messages in thread
From: Bruno Wolff III @ 2005-04-25 04:23 UTC (permalink / raw)
To: Theodore Petrosky <tedpet5@yahoo.com>; +Cc: pgsql-sql
On Sun, Apr 24, 2005 at 13:08:04 -0700,
Theodore Petrosky <tedpet5@yahoo.com> wrote:
> how do I get an interval '1 day 1 hour' to display as
> '25 hours'. I am hunting in the docs (and googling)
> and either I am blind or I need a special function?
>
> Is there an easy way?
EXTRACT epoch from the interval and divide by 3600 and concatenate to ' hours'.
area=> select extract(epoch from '1 day 1 hour'::interval)/3600 || ' hours';
?column?
----------
25 hours
(1 row)
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: to_char(interval) ?
@ 2005-04-25 11:48 Theodore Petrosky <tedpet5@yahoo.com>
0 siblings, 0 replies; 3+ messages in thread
From: Theodore Petrosky @ 2005-04-25 11:48 UTC (permalink / raw)
To: Bruno Wolff III <bruno@wolff.to>; +Cc: pgsql-sql
This is perfect.
select extract(epoch from '1 day 1 hour 15
minute'::interval)/3600 || 'hours';
?column?
------------
25.25hours
(1 row)
I must have looked at this for hours and not seen the
'interval' part of the epoch...
Thanks,
Ted
--- Bruno Wolff III <bruno@wolff.to> wrote:
> On Sun, Apr 24, 2005 at 13:08:04 -0700,
> Theodore Petrosky <tedpet5@yahoo.com> wrote:
> > how do I get an interval '1 day 1 hour' to display
> as
> > '25 hours'. I am hunting in the docs (and
> googling)
> > and either I am blind or I need a special
> function?
> >
> > Is there an easy way?
>
> EXTRACT epoch from the interval and divide by 3600
> and concatenate to ' hours'.
>
> area=> select extract(epoch from '1 day 1
> hour'::interval)/3600 || ' hours';
> ?column?
> ----------
> 25 hours
> (1 row)
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2005-04-25 11:48 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-04-24 20:08 to_char(interval) ? Theodore Petrosky <tedpet5@yahoo.com>
2005-04-25 04:23 ` Bruno Wolff III <bruno@wolff.to>
2005-04-25 11:48 Re: to_char(interval) ? Theodore Petrosky <tedpet5@yahoo.com>
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