Re: How cast interval to minutes as number?

From: Andreas Kretschmer <akretschmer(at)spamfence(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: How cast interval to minutes as number?
Date: 2007-11-25 08:53:22
Message-ID: 20071125085321.GA20882@KanotixBox
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Andreas <maps(dot)on(at)gmx(dot)net> schrieb:

> 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.

Okay, lets assume i want to know how old is my daughter, in minutes:

test=# select EXTRACT (EPOCH FROM now() - '2007-07-28 09:15:00'::timestamp )::int/60;
?column?
----------
172896
(1 row)

You can exchange the fix timestamp with a column from a table, no
problem.

Hope that helps, Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly." (unknow)
Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Andreas 2007-11-25 09:03:19 Re: How cast interval to minutes as number?
Previous Message Maximilian Tyrtania 2007-11-25 08:32:12 Re: How cast interval to minutes as number?