Skip site navigation (1) Skip section navigation (2)

Re: How cast interval to minutes as number?

From: Andreas <maps(dot)on(at)gmx(dot)net>
To: Maximilian Tyrtania <mty(at)fischerappelt(dot)de>
Cc: ListaPostgre <pgsql-novice(at)postgresql(dot)org>
Subject: Re: How cast interval to minutes as number?
Date: 2007-11-25 09:03:19
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
Maximilian Tyrtania schrieb:
> Am 25.11.2007 8:43 Uhr schrieb "Andreas" unter <maps(dot)on(at)gmx(dot)net>:
>> 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.
> I think the "age" function might do what you are looking for.

Not really.
The doc says age results to months and days.
I need minutes for intraday calculations.

There must be some more exact way to store time differences.
As far as I understood intervals are abstracts but no fix representation 
of a distinct timespan, like INTERVAL '1 month' could equally be 
February or August, even though August has more days.

It's still nice,too, to be able to add 2 months to a date and get the 
same day 2 months later without considering the actual number of days 
between the two dates.

In response to

pgsql-novice by date

Next:From: AndreasDate: 2007-11-25 09:10:08
Subject: Re: How cast interval to minutes as number?
Previous:From: Andreas KretschmerDate: 2007-11-25 08:53:22
Subject: Re: How cast interval to minutes as number?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group