Re: to_char(interval) ?

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Theodore Petrosky <tedpet5(at)yahoo(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: to_char(interval) ?
Date: 2005-04-25 04:23:27
Message-ID: 20050425042327.GA2882@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Sun, Apr 24, 2005 at 13:08:04 -0700,
Theodore Petrosky <tedpet5(at)yahoo(dot)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)

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2005-04-25 04:53:37 Re: Matching the MYSQL "Describe <table-name>" command
Previous Message John DeSoi 2005-04-25 00:36:53 Re: php wrapper