Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XZMjI-0005oI-86 for pgsql-interfaces@arkaria.postgresql.org; Wed, 01 Oct 2014 16:26:16 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XZMjH-0005ZU-IK for pgsql-interfaces@arkaria.postgresql.org; Wed, 01 Oct 2014 16:26:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XZMjG-0005ZM-Jh for pgsql-interfaces@postgresql.org; Wed, 01 Oct 2014 16:26:14 +0000 Received: from mout.kundenserver.de ([212.227.17.10]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XZMjD-0003eY-GB for pgsql-interfaces@postgresql.org; Wed, 01 Oct 2014 16:26:13 +0000 Received: from thilo.site (x590cabfd.dyn.telefonica.de [89.12.171.253]) by mrelayeu.kundenserver.de (node=mreue104) with ESMTP (Nemesis) id 0Mgegh-1XvB0Y3qVT-00O0yL; Wed, 01 Oct 2014 18:26:10 +0200 From: thilo@riessner.de To: pgsql-interfaces@postgresql.org Subject: libpq binary data Date: Wed, 01 Oct 2014 18:26:08 +0200 Message-ID: <3808965.tNLrlL6qTR@thilo.site> User-Agent: KMail/4.11.5 (Linux/3.11.10-21-desktop; KDE/4.11.5; x86_64; ; ) MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V02:K0:fDqoxXYsWZJF3Qq7RnV9Fewi8lx+D6mjQjADNIBVw+t EfkEPwT8Iz8shtqZazMSqEDGcrXdRAm9fJQt82D78hXeenj38U GtF1a14Y8WCaJaRUwzcGWL5/cU7Ut2hlGoSI4Avn24T2Vn97Yt 4rnyPMxb+A16z+BBLLK44vY77HxEi46bTqloPNC023NBX7mGfx cjBqXO4Z25nentXyLFyG0u+KP2RZ3eglappZbVx1zHjtWFuR9Y GIo+RGORqPlkrmaElO6ZWJN76v2o3NHiDrS+fUPkfBQQF7l3WQ Jlpqs1RsW/y0Rnj2za49MGWwKc1pcFv9E2V+8XlGKteVrKVmA7 M1urqYye5OYnavXHETNM= X-UI-Out-Filterresults: notjunk:1; X-Pg-Spam-Score: -2.1 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-interfaces Precedence: bulk Sender: pgsql-interfaces-owner@postgresql.org Hello, I try to get the epoch value of a date via the PQexecParams(conn, "SELECT extract(epoch from date + time) as epoch, content FROM daten .....); In that database, the timestamp ist stored in the two fields date and time. I want to get this data in binary form. The PQfsize(res, 1); tells me, that the size of the returned data is 8 byte (in contrast to the standard size of epoch, which is meant to be 4 byte) I don't manage to get the epoch valule (seconds since 1970) from that returned value. After ntohll (which I wrote as a wrapper around ntohl for long int, see below) it is a very huge value (4743709917079142400) but it should be 1412179252 as I get it from the psql interface, when I type in the same command. What am I missing or doing wrong? Thanks for any help in advance Thilo unsigned long int ntohll(long int x) { if (ntohl(1) == 1) return x; else return (long int) (ntohl((int)((x << 32) >> 32))) << 32 | (long int)ntohl(((int)(x >> 32))); } -- Sent via pgsql-interfaces mailing list (pgsql-interfaces@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-interfaces