Re: fomatting an interval (resend)
Alvaro Herrera <alvherre@dcc.uchile.cl>
From: Alvaro Herrera <alvherre@dcc.uchile.cl>
To: Forest Wilkinson <lyris-pg@tibit.com>
Cc: pgsql-general@postgresql.org
Date: 2003-05-15T02:02:57Z
Lists: pgsql-hackers
On Wed, May 14, 2003 at 10:12:41AM -0700, Forest Wilkinson wrote: > >Here is one consistent conversion that will show you the number of seconds > >without anything else: > > > >select round(extract(epoch from finish) - extract(epoch from start)) from timetable; > > Hmm. The postgres 7.3 docs give me the impression that extract() will > return one field of a multi-field value, such as '4 days' from '2 > years 4 days 15:01'. Experimenting in psql seems to prove this. For > example: Extracting(epoch) from an interval is a special case. It returns the total number of seconds in the interval. Note that it is quite different from extracting(epoch) from a timestamp. -- Alvaro Herrera (<alvherre[a]dcc.uchile.cl>) "Si quieres ser creativo, aprende el arte de perder el tiempo"