pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas Kretschmer <akretschmer@spamfence.net>
To: pgsql-sql@postgresql.org
Subject: Re: Format intervall as hours/minutes etc
Date: Sun, 16 Sep 2007 13:14:27 +0200
Message-ID: <20070916111427.GA13886@KanotixBox> (raw)
In-Reply-To: <200709161300.53257.andreak@officenet.no>
References: <200709161300.53257.andreak@officenet.no>

Andreas Joseph Krogh <andreak@officenet.no> schrieb:

> Hi all. Any hint on how to format this interval as number of hour/seconds etc?
> select age('2007-09-22 17:00'::timestamp, '2000-02-20 18:00'::timestamp);
>               age
> -------------------------------
>  7 years 7 mons 1 day 23:00:00

You can use extract(epoch, from ...) like this:

test=*# select extract(epoch from '2007-09-22 17:00'::timestamp) - extract (epoch from '2000-02-20 18:00'::timestamp);
 ?column?
-----------
 239407200
(1 row)

Now you can calculate the hours and so on.

Andreas
-- 
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."    (unknow)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°



view thread (6+ messages)  latest in thread

Message-ID: <20070916111427.GA13886@KanotixBox>
Permalink:  ../20070916111427.GA13886@KanotixBox/
Also on:    postgresql.org/message-id/20070916111427.GA13886@KanotixBox

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: akretschmer@spamfence.net
  Subject: Re: Format intervall as hours/minutes etc
  In-Reply-To: <20070916111427.GA13886@KanotixBox>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox