X-Original-To: pgsql-sql@postgresql.org Received: from ns2.boxsoft.com (dsl092-062-212.lax1.dsl.speakeasy.net [66.92.62.212]) by postgresql.org (Postfix) with ESMTP id 93478476241 for ; Tue, 11 Mar 2003 21:53:53 -0500 (EST) Received: from 3eye.boxsoft.com (3eye.boxsoft.com [66.92.62.215]) by ns2.boxsoft.com (8.12.8/8.12.8) with ESMTP id h2C2sEmG001681 for ; Tue, 11 Mar 2003 18:54:14 -0800 Received: from 3eye.boxsoft.com (localhost [127.0.0.1]) by 3eye.boxsoft.com (8.12.8/8.12.8) with ESMTP id h2C2v4uL025036 for ; Tue, 11 Mar 2003 18:57:04 -0800 Received: (from patrick@localhost) by 3eye.boxsoft.com (8.12.8/8.12.8/Submit) id h2C2v4Qw025035 for pgsql-sql@postgresql.org; Tue, 11 Mar 2003 18:57:04 -0800 Date: Tue, 11 Mar 2003 18:57:04 -0800 From: patrick To: pgsql-sql@postgresql.org Subject: converting time_t to timestamp? Message-ID: <20030311185704.D24959@3eye.boxsoft.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i X-Archive-Number: 200303/269 X-Sequence-Number: 12309 Greetings, I'm reposting this question since I received zero replies from my original post (maybe the original subject line was misleading). I've just^W upgraded from PostgreSQL 7.1.2 to 7.3.2. In 7.1.2 I was able to use the output of time(2) (and the like) to insert into a field of timestamp type. First thing i noticed with the upgrade was that the following broke: in 7.1.2 => select timestamp ( 1046923200 ); timestamp ------------------------ 2003-03-05 20:00:00-08 (1 row) in 7.3.2 => select timestamp ( 1046923200 ); ERROR: TIMESTAMP(1046923200) precision must be between 0 and 6 Can anyone point me to a work-around? I notice that I can use abstime( 1046923200 ) to get the desired result. But is this the optimal way to do this? My client application uses mktime(3) and then forms the SQL statement to insert into a table of the form: sprintf( sql_stmt, "insert into tab1 " " ( ... , target_timestamp, ... ) " "values ( ... , timestamp( %lu ), ... ) ", ..., mktime( &tm ) ); /* * You get the idea. */ Thanks in advance, sidster -- They who would sacrifice freedom for security will have neither. -Ben Franklin