On Thu, Jan 31, 2002 at 07:04:59PM +0100, Bruno Boettcher wrote:
>
> is there a way to feed the perl time directly without any transformation
> as a valid timestamp to a postgres database?
....
> but formatting the thing before putting it into the DB seems a bit
> cumbersome....
Not directly, but you can get the DB to do the conversion work:
testing=# select ('epoch'::timestamp + 1012499946::interval) as foo;
foo
------------------------
2002-01-31 17:59:06+00
(1 row)
Or do whatever you want to do with it. The basic idea is that you use
the built-in magic constant 'epoch', which gives you the Unix epoch as
a timestamp, then cast your time to the postgres 'interval' type, and
add them together. Notice that when postgres casts integer to interval
it assumes the units are seconds (which is what you want in this case).
Richard