Re: How cast interval to minutes as number? - Mailing list pgsql-novice

From Andreas Kretschmer
Subject Re: How cast interval to minutes as number?
Date
Msg-id 20071125085321.GA20882@KanotixBox
Whole thread Raw
In response to How cast interval to minutes as number?  (Andreas <maps.on@gmx.net>)
Responses Re: How cast interval to minutes as number?
List pgsql-novice
Andreas <maps.on@gmx.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°

pgsql-novice by date:

Previous
From: Maximilian Tyrtania
Date:
Subject: Re: How cast interval to minutes as number?
Next
From: Andreas
Date:
Subject: Re: How cast interval to minutes as number?