Re: Thanks and questions...

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Thanks and questions...
Дата
Msg-id 2038.964824821@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Thanks and questions...  (George Robinson II <george.robinson@eurekabroadband.com>)
Ответы Re: Thanks and questions...  (Samuel Sieb <samuel@sieb.net>)
Список pgsql-general
George Robinson II <george.robinson@eurekabroadband.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

В списке pgsql-general по дате отправления:

Предыдущее
От: George Robinson II
Дата:
Сообщение: Thanks and questions...
Следующее
От: "Jason C. Pion"
Дата:
Сообщение: Hopefully simple date conversion question