Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 8007F64FCD8 for ; Mon, 13 Oct 2008 05:23:49 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 99017-07 for ; Mon, 13 Oct 2008 05:23:37 -0300 (ADT) X-Greylist: delayed 00:30:03.32748 by SQLgrey-1.7.6 Received: from fabaglexfr.fabasoft.com (fabaglexfr.fabasoft.com [192.84.221.196]) by postgresql.org (Postfix) with ESMTP id CC36264FCD4 for ; Mon, 13 Oct 2008 05:23:36 -0300 (ADT) Received: from FABAMAIL.fabagl.fabasoft.com ([10.10.5.136]) by fabaglexfr.fabasoft.com with InterScan Messaging Security Suite; Mon, 13 Oct 2008 09:52:47 +0200 Received: from 192.168.121.105 ([192.168.121.105]) by FABAMAIL.fabagl.fabasoft.com ([10.10.5.135]) with Microsoft Exchange Server HTTP-DAV ;Mon, 13 Oct 2008 07:53:25 +0000 Received: from vie063 by FABAMAIL.fabagl.fabasoft.com; 13 Oct 2008 07:53:01 +0000 Subject: Timestamp with libpq From: Jakob Lechner Reply-To: jakob.lechner@applstrudl.com To: pgsql-interfaces@postgresql.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Organization: appl.strudl Software GmbH Date: Mon, 13 Oct 2008 09:53:01 +0200 Message-Id: <1223884381.3502.10.camel@vie063.fabagl.fabasoft.com> Mime-Version: 1.0 X-Mailer: Evolution 2.8.0 (2.8.0-33.el5) X-imss-version: 2.051 X-imss-result: Passed X-imss-scores: Clean:99.17453 C:2 M:3 S:5 R:5 X-imss-settings: Baseline:2 C:3 M:2 S:3 R:4 (0.1500 0.1500) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200810/3 X-Sequence-Number: 6804 Hello everybody, I'm trying to convert timestamp values returned by an SQL query into an unix time_t. I'm using the libpq library. For executing the query I use "PQexecParams" with the parameter "resultFormat" set to 1 in order to obtain results in binary format. The table I'm fetching data from was created with the following statement: create table testtable (c timestamp); The statement executed by "PQexecParams" is a simple "select"-statement: select * from testtable; I've read that postgres internally handles timestamps as double numbers, where the timestamp is represented in seconds since 2000-01-01. Thus, I assumed the data returned by "PQgetvalue" for the timestamp field is encoded in this format. Then I wrote a little routine, which takes the double number obtained from "PQgetvalue" and converts it into an unix time_t. This works perfectly if the postgres server (version 8.1.4-1.1) runs on RHEL but if I query the data from a postgres server (version 8.1.4-1.3) runnning on SLES the result totally wrong. Any ideas? Best regards Jakob Lechner --=20 Jakob Lechner Research & Development appl.strudl Software GmbH Honauerstra=C3=9Fe 4 A-4020 Linz Tel.: [+43] (70) 60 61 62 Fax: [+43] (70) 60 61 62-609 E-Mail: jakob.lechner@applstrudl.com Web: http://www.applstrudl.com Handelsgericht Linz, FN 303988 t