Actually, I've done this before. And, uh, you can check out my blog for
On Mon, Oct 13, 2008 at 3:53 PM, Jakob Lechner <jakob(dot)lechner(at)applstrudl(dot)com
> 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
> 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
> Jakob Lechner
> Research & Development
> appl.strudl Software GmbH
> Honauerstraße 4
> A-4020 Linz
> Tel.: [+43] (70) 60 61 62
> Fax: [+43] (70) 60 61 62-609
> E-Mail: jakob(dot)lechner(at)applstrudl(dot)com
> Web: http://www.applstrudl.com
> Handelsgericht Linz, FN 303988 t
> Sent via pgsql-interfaces mailing list (pgsql-interfaces(at)postgresql(dot)org)
> To make changes to your subscription:
Life is too short for dial-up.
In response to
pgsql-interfaces by date
|Next:||From: Jakob Lechner||Date: 2008-10-13 09:57:23|
|Subject: Re: Timestamp with libpq|
|Previous:||From: Jakob Lechner||Date: 2008-10-13 07:53:01|
|Subject: Timestamp with libpq|