X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 44FF2D1C9D8 for ; Fri, 1 Aug 2003 12:50:32 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 41427-02 for ; Fri, 1 Aug 2003 09:49:25 -0300 (ADT) Received: from mail2.n2bb.com (mail2.n2bb.com [66.0.13.202]) by svr1.postgresql.org (Postfix) with ESMTP id 6BBE7D1C9DB for ; Fri, 1 Aug 2003 09:50:27 -0300 (ADT) Received: from poopelstilskin.it.n2bb.com ([10.250.10.96] unverified) by mail2.n2bb.com with Microsoft SMTPSVC(5.0.2195.6713); Fri, 1 Aug 2003 08:51:43 -0400 Content-Type: text/plain; charset="iso-8859-1" From: Mike Rylander Reply-To: miker@n2bb.com Organization: N2 Broadband To: teknokrat@yahoo.com, pgsql-sql@postgresql.org Subject: Re: converting interval to timestamp Date: Fri, 1 Aug 2003 08:41:49 -0400 User-Agent: KMail/1.4.3 References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200308010841.50193.miker@n2bb.com> X-OriginalArrivalTime: 01 Aug 2003 12:51:43.0643 (UTC) FILETIME=[A8DD76B0:01C3582B] X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/3 X-Sequence-Number: 14619 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 If the number of seconds between timestamps is acceptable then this is the solution I use: SELECT ABS(EXTRACT(EPOCH FROM t.field1) - EXTRACT(EPOCH FROM t.field2)) AS diff FROM table AS t; Adjust to your column and WHERE needs. One caveat: this only works for dates within the UNIX epoch ( after 1969-12-31). On Thursday 31 July 2003 12:05 pm, teknokrat wrote: > The difference of two dates/timestamps always gives an interval. is > there a way to convert this interval into number such as number of > milliseconds or number of days? > > Also does anyone know what field type an interval would map to in jdbc? > > thanks > > > > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match - -- Mike Rylander -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE/KmAOgRDV1fFA+3cRAgbVAJ9B03Pxsn+N+Xg2C/a4gw3j28KSsgCeNA7+ y2rYedgRdTY/BiNSfVJTvOs= =kVkm -----END PGP SIGNATURE-----