Re: Cast timestamptz to/from integer?

Поиск
Список
Период
Сортировка
От Bartosz Dmytrak
Тема Re: Cast timestamptz to/from integer?
Дата
Msg-id CAD8_UcZUo8w-NSvxzALbUOy+vwCOxb78_n-=fZhg1deG3cQijg@mail.gmail.com
обсуждение исходный текст
Ответ на Cast timestamptz to/from integer?  (Chris Angelico <rosuav@gmail.com>)
Ответы Re: Cast timestamptz to/from integer?
Список pgsql-general
I think You can use epoch


SELECT TIMESTAMP WITH TIME ZONE 'epoch' + 982384720.12 * INTERVAL '1 second';
Regards,
Bartek


2012/4/3 Chris Angelico <rosuav@gmail.com>
I work a lot with Unix times as integers, but would like to store them
in Postgres as 'timestamp(0) with time zone' for convenience and
readability. Unfortunately the syntax to translate between the two is
a little cumbersome, so I'm looking at hiding it away behind a
function - or a cast. However, the CREATE CAST docs say that I have to
be the owner of either the source or target types, which presumably
means I can't define a cast from timestamptz to int.

Is there a workaround for this?

Chris Angelico

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

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

Предыдущее
От: Bartosz Dmytrak
Дата:
Сообщение: Re: Please help me to take a look of the erros in my functions. Thanks.
Следующее
От: Chris Angelico
Дата:
Сообщение: Re: Cast timestamptz to/from integer?