Re: Cast: timestamp to integer

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: Cast: timestamp to integer
Дата
Msg-id 20030612110321.R31475-100000@megazone23.bigpanda.com
обсуждение исходный текст
Ответ на Cast: timestamp to integer  (Michal Durys <joe@anime.com.pl>)
Список pgsql-general
On Thu, 12 Jun 2003, Michal Durys wrote:

> Hello,
>
> I hope it's not a question for psql-novice. ;-)
>
> I'd like to convert timestamp and date fields to intergers.
> Unfortunately cast() says it's impossible:
>
> ERROR: Cannot cast type date to integer
> ERROR: Cannot cast type timestamp without time zone to integer
>
> I'm quite sure it should be possible somehow. After all timestamp is
> (AFAIR) number of seconds counted from 1970.

I believe EXTRACT has an "epoch" unit that is seconds from 1970 as a
double which you can cast to an int.


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

Предыдущее
От: "Ian Harding"
Дата:
Сообщение: Re: Postgres performance comments from a MySQL user
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: LAST_INSERT_ID equivalent