George Robinson II <[EMAIL PROTECTED]> writes:
>       What approach would be the most efficient way to accomplish this goal? 
> With what language or tools would you recommend?  If I were to leave the
> time as a int4, epoch time, what would the select look like to return
> other time formats?

Presently the easiest way to get from Unix time to a stored timestamp
datum is to coerce to abstime first.

regression=# create table foo (f1 timestamp);
CREATE
-- this doesn't work:
regression=# insert into foo values(964824656);
ERROR:  Attribute 'f1' is of type 'timestamp' but expression is of type 'int4'
        You will need to rewrite or cast the expression
-- but this does:
regression=# insert into foo values(abstime(964824656));
INSERT 308042 1
regression=# select * from foo;
           f1
------------------------
 2000-07-28 18:50:56-04
(1 row)

I don't think this'd work in the context of a COPY command,
unfortunately, but it works fine in an INSERT.

                        regards, tom lane

Reply via email to