X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 52725D1B193 for ; Wed, 16 Jun 2004 04:30:32 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 27025-06 for ; Wed, 16 Jun 2004 07:30:24 +0000 (GMT) Received: from mail.cobweb.nl (mx1.cobweb.nl [80.242.96.4]) by svr1.postgresql.org (Postfix) with ESMTP id 97788D1B170 for ; Wed, 16 Jun 2004 04:30:20 -0300 (ADT) Received: from farcourier.com (dp3-26.dsl.cobweb.nl [193.67.120.154] (may be forged)) by mail.cobweb.nl (8.12.8/8.12.7) with ESMTP id i5G7UQAt048555 for ; Wed, 16 Jun 2004 09:30:26 +0200 (CEST) (envelope-from s.vanroye@Farcourier.com) Subject: Re: Your question in postgresql.org forum (Diff. between two times as a numeric value in a stored proc) MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Date: Wed, 16 Jun 2004 09:27:24 +0200 Message-ID: <736CEAA26E7E3F48943458F760E7A32603B622@fs1300.farcourier.com> Content-Class: urn:content-classes:message X-MimeOLE: Produced By Microsoft Exchange V6.0.5762.3 X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Your question in postgresql.org forum thread-index: AcRS+XlV2mu+GwlcToK/ROClom8zxwAd+KRQ From: "Stijn Vanroye" To: "togy@icube" Cc: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/138 X-Sequence-Number: 18083 Hello Martin, There's not much hint to it, here's a solution instead :) You can make use of several built-in functions to handle strings, date/time= values etc. Take a look at chapter 9: Functions and Operators of your Pos= tgreSQL documentation all available functions are explained there.=20 To solve my problem I used the extract EXTRACT (field FROM source) function= , as described in paragraph 9.8.1.=20 You can use it to extract a certain field form your timestamp vield, for ex= ample: extract (hour from timestamp '2004-16-04 09:21:52') returns 9 SELECT EXTRACT(EPOCH FROM INTERVAL '5 days 3 hours'); Result: 442800 EPOCH will return the number of seconds. You can multiply those by n*60, de= pending if you want minutes or hours. At first I used a different calculation, but this one should be less work := ). I hope you're problem is solved that way. I took the liberty of CC-ing the postgresql mailinglist so other's having a= similar problem can read about this solution too. It's all about the (open= -source)-community isn't it :) Kind regards, Stijn Vanroye -----Original Message----- From: togy@icube [mailto:martin.tongel@icubestudio.com] Sent: dinsdag 15 juni 2004 19:08 To: Stijn Vanroye Subject: Your question in postgresql.org forum Hello Stijn, I read your question in postgresql.org forum published under sunject "Diffe= rence between two times as a numeric value in a stored procedure" I am currently solving the same problem... Did you solve it somehow? Can yo= u give a hint please? Best Regards, Martin Tongel