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

Re: BUG #1107: Missing feature: interval <-> numeric quantity conversion

From: Francisco Olarte Sanz <folarte(at)peoplecall(dot)com>
To: "PostgreSQL Bugs List" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #1107: Missing feature: interval <-> numeric quantity conversion
Date: 2004-03-18 17:02:47
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
> Having two timestamps it is common need to know how many
> seconds/minutes/hours/days/etc. passed from one to the other. However there
> is no easy way to do this task.

> The basic idea is subtracting the two timestamps. However it gives a data
> type called "interval". The thing I would like to have is a function that
> takes the "interval" and outputs it's length. Currently when I want a
> program to know how long an interval is I must let it parse the interval
> textual representation (which may be subject to change) to obtain what I
> want.

	I do this a lot, just try 'extract(epoch from the_interval)' ( actually in my 
code i use things like 'extract(epoch from age(disconnect_time, 
connect_time))' where *_time are of type 'timestamp with time zone' and works 
like a charm, even across time zone changes.

Francisco Olarte..

In response to

pgsql-bugs by date

Next:From: John MuzzattiDate: 2004-03-19 02:47:11
Subject: PostgreSQL & Red Hat AS 2.1
Previous:From: Dave PageDate: 2004-03-18 16:53:09
Subject: Re: BUG #1109: Testing again

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