Re: Thanks and questions...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: George Robinson II <george(dot)robinson(at)eurekabroadband(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Thanks and questions...
Date: 2000-07-28 22:53:41
Message-ID: 2038.964824821@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

George Robinson II <george(dot)robinson(at)eurekabroadband(dot)com> 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jason C. Pion 2000-07-28 23:00:32 Hopefully simple date conversion question
Previous Message George Robinson II 2000-07-28 22:41:07 Thanks and questions...