## Re: How cast interval to minutes as number?

From: Andreas Maximilian Tyrtania ListaPostgre Re: How cast interval to minutes as number? 2007-11-25 09:03:19 47493A57.1050101@gmx.net (view raw, whole thread or download thread mbox) 2007-11-25 07:43:22 from Andreas  2007-11-25 08:32:12 from Maximilian Tyrtania   2007-11-25 09:03:19 from Andreas  2007-11-25 08:53:22 from Andreas Kretschmer   2007-11-25 09:10:08 from Andreas 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.

```

### pgsql-novice by date

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