From: | Karel Zak <zakkr(at)zf(dot)jcu(dot)cz> |
---|---|
To: | Eel <eel(at)javabox(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Converting/formatting timestamp arithmetic |
Date: | 2002-03-14 08:32:21 |
Message-ID: | 20020314093221.A11295@zf.jcu.cz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, Mar 07, 2002 at 05:42:00PM -0800, Eel wrote:
> Hi,
> Is there any easy way to convert the result of timestamp
> arithmetic to a simple decimal number?
>
> I have something like:
>
> select current_timestamp - timein as daysat from transcations
>
> daysat looks like:
>
> 3 days 12:00:00
>
> I want it to look like:
>
> 3.5
test=# select date_part('d', '3 days 12:00:00'::interval) + (1 / (24 /
date_part('h', '3 days 12:00:00'::interval)));
?column?
----------
3.5
test=# select date_part('d', '3 days 6:00:00'::interval) + (1 / (24 /
date_part('h', '3 days 6:00:00'::interval)));
?column?
----------
3.25
> I fooled around a bit to_number(text, text). It seems like
IMHO better is extract relavant values and count it.
Karel
--
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
From | Date | Subject | |
---|---|---|---|
Next Message | Erwin Ambrosch | 2002-03-14 09:08:13 | JDBC-Question |
Previous Message | Jean-Michel POURE | 2002-03-14 08:27:17 | Re: Distributed databases |