Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 07BF54764AF for ; Mon, 20 May 2002 13:22:18 -0400 (EDT) Received: from fw.mccons.net (adsl-65-64-105-41.dsl.kscymo.swbell.net [65.64.105.41]) by postgresql.org (Postfix) with ESMTP id D9749476845 for ; Mon, 20 May 2002 12:35:17 -0400 (EDT) Received: (from root@localhost) by fw.mccons.net (8.11.3/8.11.4) id g4KGZNY83128; Mon, 20 May 2002 11:35:23 -0500 (CDT) (envelope-from bmccane@mccons.net) Received: from localhost (localhost [127.0.0.1]) by fw.mccons.net (8.11.3/8.11.4av) with ESMTP id g4KGZ7c82871; Mon, 20 May 2002 11:35:07 -0500 (CDT) (envelope-from bmccane@mccons.net) Date: Mon, 20 May 2002 11:35:07 -0500 (CDT) From: Brian McCane To: Gareth Kirwan Cc: Subject: Re: Interval to number In-Reply-To: <00fb01c1fff4$e5030cd0$55eaa8c0@gbjk1> Message-ID: <20020520113223.I80087-100000@fw.mccons.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS perl-11 X-Razor-Spam-ID: 39ef5d41cb94a0ae18729444f39f4d08488088e1 X-Archive-Number: 200205/156 X-Sequence-Number: 4331 EXTRACT is your friend :) SELECT EXTRACT(EPOCH FROM max(occurrance) - min(occurrance))::integer ; - brian k=# SELECT EXTRACT(EPOCH FROM now() - '2001-01-01') ; date_part ---------------- 43583467.94995 (1 row) On Mon, 20 May 2002, Gareth Kirwan wrote: > > Postgres 7.2 > I have an interval selected from a max(occurance) - min(occurance) where > bla. > I now want to multiply this by a rate - to create a charge... > > If I use to_char( interval, 'SSSS'); > I will get a seconds conversion - but that works on seconds since midnight - > hence > with a one day period. > > Are there any better ways of converting a timestamp to an integer? > > > Thanks > > Gareth > > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/users-lounge/docs/faq.html > Wm. Brian McCane | Life is full of doors that won't open Search http://recall.maxbaud.net/ | when you knock, equally spaced amid those Usenet http://freenews.maxbaud.net/ | that open when you don't want them to. Auction http://www.sellit-here.com/ | - Roger Zelazny "Blood of Amber"