Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 35D809F9BE0 for ; Sun, 16 Sep 2007 08:09:45 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 30649-07 for ; Sun, 16 Sep 2007 08:09:42 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from 137086.vserver.de (vs137086.vserver.de [62.75.137.86]) by postgresql.org (Postfix) with ESMTP id 0E4F19F9BD7 for ; Sun, 16 Sep 2007 08:09:41 -0300 (ADT) Received: from a-kretschmer.de (p54B3802C.dip0.t-ipconnect.de [84.179.128.44]) (authenticated bits=0) by 137086.vserver.de (8.12.8/8.12.8) with ESMTP id l8GB9cKE022477 for ; Sun, 16 Sep 2007 13:09:39 +0200 Received: from kretschmer by a-kretschmer.de with local (Exim 4.61) (envelope-from ) id 1IWs55-0003gk-DM for pgsql-sql@postgresql.org; Sun, 16 Sep 2007 13:14:27 +0200 Date: Sun, 16 Sep 2007 13:14:27 +0200 From: Andreas Kretschmer To: pgsql-sql@postgresql.org Subject: Re: Format intervall as hours/minutes etc Message-ID: <20070916111427.GA13886@KanotixBox> References: <200709161300.53257.andreak@officenet.no> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <200709161300.53257.andreak@officenet.no> X-OS: Debian/GNU Linux - weil ich es mir Wert bin! X-GPG-Fingerprint: EE16 3C01 7B9C 10F7 2C8B 3B86 4DB3 D9EE 7F45 84DA X-Message-Flag: "Windows" is not the answer. "Windows" is the question and the answer is "no"! X-Lugdd: Gerd Kube X-Info: My name is root. Just root. And I am licensed to kill -9 User-Agent: mutt-ng 1.5.9i (Linux) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200709/116 X-Sequence-Number: 29329 Andreas Joseph Krogh 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°