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: 47493A57.1050101@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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.
>
> http://www.postgresql.org/docs/8.2/interactive/functions-datetime.html
>

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

Browse pgsql-novice by date

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