Re: How cast interval to minutes as number?

From: Maximilian Tyrtania <mty(at)fischerappelt(dot)de>
To: Andreas <maps(dot)on(at)gmx(dot)net>, ListaPostgre <pgsql-novice(at)postgresql(dot)org>
Subject: Re: How cast interval to minutes as number?
Date: 2007-11-25 08:32:12
Message-ID: C36EF19C.15436%mty@fischerappelt.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi Andreas,

Am 25.11.2007 8:43 Uhr schrieb "Andreas" unter <maps(dot)on(at)gmx(dot)net>:

> Hi,
>
> I have a column with timestamps --> some_ts .
> I'd like to calculate the amount of time between this timestamp and NOW().
>
> select some_ts - NOW() from some_table;
>
> This results in a column of type interval.
>
> How would I get this interval converted into e.g. minutes.
> I need the whole value converted not just the 0-59 minutes part.
> Like a difference of exactly 1 day = 24*60 minutes rather than 0
> minutes if I just take the minute-part.
>
> Seconds would be fine, too.
>
>
> select EXTRACT (EPOCH FROM INTERVAL some_ts - NOW()) from ....
>
> gets me a syntax error
>
> Help?

I think the "age" function might do what you are looking for.

http://www.postgresql.org/docs/8.2/interactive/functions-datetime.html

Best wishes,

- Maximilian Tyrtania | mty(at)fischerappelt(dot)de
fischerAppelt Kommunikation GmbH
Tucholskystr.18 | D-10117 Berlin | Germany
Tel. ++49-30-726146-728
http://www.fischerappelt.de

--

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Andreas Kretschmer 2007-11-25 08:53:22 Re: How cast interval to minutes as number?
Previous Message Andreas 2007-11-25 07:43:22 How cast interval to minutes as number?