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 8DD3355C0A for ; Thu, 3 Mar 2005 07:21:58 +0000 (GMT) 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 64419-03 for ; Thu, 3 Mar 2005 07:21:48 +0000 (GMT) Received: from mail1.elevating.com (wsip-68-99-77-237.tu.ok.cox.net [68.99.77.237]) by svr1.postgresql.org (Postfix) with ESMTP id 7E06856380 for ; Thu, 3 Mar 2005 07:21:47 +0000 (GMT) Received: from bretsony.brets.elevating.com (bretsony.brets.elevating.com [10.23.0.139]) by mail1.elevating.com (8.11.6/8.11.6) with ESMTP id j237LcK18989 for ; Thu, 3 Mar 2005 01:21:38 -0600 Subject: Re: definative way to place secs from epoc into timestamp From: Bret Hughes To: postgresql sql list In-Reply-To: <17735.1109831102@sss.pgh.pa.us> References: <1109780719.28180.86.camel@bretsony> <13089.1109793126@sss.pgh.pa.us> <1109794066.27857.100.camel@bretsony> <13466.1109795186@sss.pgh.pa.us> <1109828560.27905.137.camel@bretsony> <17735.1109831102@sss.pgh.pa.us> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 (1.0.8-9.7x.1) Date: 03 Mar 2005 01:21:38 -0600 Message-Id: <1109834498.27905.142.camel@bretsony> Mime-Version: 1.0 X-Elevating-MailScanner: Found to be clean X-Elevating-MailScanner-SpamCheck: not spam, SpamAssassin (score=-1.5, required 5, BAYES_00 -1.50) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200503/37 X-Sequence-Number: 20516 On Thu, 2005-03-03 at 00:25, Tom Lane wrote: > Bret Hughes writes: > > create function int2ts(integer) returns timestamp as ' > > SELECT ( TIMESTAMP WITH TIME ZONE \'epoch\' + $1 * INTERVAL \'1 > > second\')::timestamp without time zone; > > ' language sql; > > > create function ts2int(timestamp without time zone) returns int as ' > > select extract( \'epoch\' from $1)::integer; > > ' language sql; > > Looks good as far as it goes. Two thoughts: > > * both functions should probably be marked STRICT STABLE > (not IMMUTABLE, because they depend on the local timezone setting). > > * have you considered allowing the numeric values to be float8 instead > of integer? There doesn't seem any reason to disallow sub-second > precision. > well no I had not considered it but am now :) I need to read some more as to the STRICT STABLE stuff, thanks for the tips. Bret