## Re: Converting interval to numeric?

From: Bruno Wolff III "Rodolfo J(dot) Paiz" Sal Dkj , pgsql-novice(at)postgresql(dot)org Re: Converting interval to numeric? 2005-02-14 21:09:05 20050214210905.GA10776@wolff.to (view raw or whole thread) 2005-02-11 01:48:06 from "Sal Dkj"  2005-02-11 04:58:25 from Bruno Wolff III   2005-02-12 00:38:23 from "Sal Dkj"   2005-02-14 18:45:01 from "Rodolfo J(dot) Paiz"    2005-02-14 21:09:05 from Bruno Wolff III pgsql-novice
On Mon, Feb 14, 2005 at 12:45:01 -0600,
"Rodolfo J. Paiz" <rpaiz(at)simpaticus(dot)com> wrote:
> On Thu, 2005-02-10 at 22:58 -0600, Bruno Wolff III wrote:
> > EXTRACT the EPOCH from the difference of the timestamps. This will give
> > you the elapsed times in seconds (as a float8 I think).
> >
>
> This is unnecessarily complicated, don't you think? Doesn't it make
> sense that there should be a way to get an interval "cast" to only hours
> or only minutes or only days?

There already is a way to do this. You get the time in seconds and divide by
60, 3600 or 86400 as appropiate. It might make sense to make some functions
to do this for some common units people might convert to. However, you
can do this yourself without much trouble.

>
> Instead of an interval *always* being shown as "3 days 4 hours 5
> minutes", why can't we get "76 hours" or "4565 minutes"? Isn't there a
> function to extract, or cast, or something? And if not, should there be?

This is really about display format. The logical place to do this would
be to_char. But to_char for intervals has had enough problems that it
has been depreciated. If someone wanted to work on it and came up with
a specification for how it was to behave, I bet that it could get
undepreciated.

### pgsql-novice by date

 Next: From: Tomas Eroles i Forner Date: 2005-02-14 22:02:15 Subject: Previous: From: Jeff Eckermann Date: 2005-02-14 20:04:20 Subject: Re: Column default