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 40D2A52D44 for ; Thu, 3 Mar 2005 06:25:06 +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 47378-06 for ; Thu, 3 Mar 2005 06:25:04 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0CF0852AAC for ; Thu, 3 Mar 2005 06:25:03 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j236P231017736; Thu, 3 Mar 2005 01:25:02 -0500 (EST) To: Bret Hughes Cc: postgresql sql list Subject: Re: definative way to place secs from epoc into timestamp In-reply-to: <1109828560.27905.137.camel@bretsony> 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> Comments: In-reply-to Bret Hughes message dated "02 Mar 2005 23:42:37 -0600" Date: Thu, 03 Mar 2005 01:25:02 -0500 Message-ID: <17735.1109831102@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/34 X-Sequence-Number: 20513 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. regards, tom lane