binary timestamp conversion

From: H Hale <hhale21(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: binary timestamp conversion
Date: 2005-10-13 13:39:45
Message-ID: 20051013133945.80741.qmail@web52312.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-interfaces

Hello,

I have a table column TIMESTAMP (6) WITHOUT TIME ZONE
that I am trying to read and write as binary. Postgres
is configured to use int64 for timestamps (not
double).

I found tm2timestamp() in libpgtypes.so that seems to
convert struct tm to a Postgres timestamp correctly
(at least for the dates I have tried). However the
corresponding function timestamp2tm() is static and
therefore not exported from the lib. I tried exporting
and using it but the results are incorrect.
Minutes,seconds and sec fractions are always
incorrect.

For example..
in: 1805-Jun-21 11:21:47.999000
out: 1805-Jun-21 11:40:02

The backend has similiar functions that take struct
pg_tm instead of struct tm as in libpgtypes.so but
these functions but are not accessible. These
functions appear to be different from the ones with
the same names in libpgtypes.so.

Other than that I can't find anything else. What do I
used to convert Postgres binary timestamps to
something usable out side of Postgres?

When doing queries either all data returned is binary
or text, can't request indivdual columns to be binary
or text (or can you?). So I need a way of converting
timestamps to an external binary format like struct tm
+ seconds fractions.

Thanks

PS. This is with v8.0.3 on Linux (intel)
BTW. Using text in/out is not a option in this case.


__________________________________
Yahoo! Music Unlimited
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-10-13 14:06:20 Re: How to inject knowledge into a Postgres database
Previous Message Stephane Bortzmeyer 2005-10-13 13:00:32 Re: Question about stored procedures

Browse pgsql-interfaces by date

  From Date Subject
Next Message Bruce Momjian 2005-10-13 23:09:24 Re: [GENERAL] binary timestamp conversion
Previous Message Fangbing Wu 2005-10-13 00:17:10 Re: How do I get more error codes from libpq