Re: update time zone in timestamps

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: update time zone in timestamps
Дата
Msg-id 20842.1070635385@sss.pgh.pa.us
обсуждение исходный текст
Ответ на update time zone in timestamps  (CSN <cool_screen_name90001@yahoo.com>)
Ответы Re: update time zone in timestamps
Список pgsql-general
CSN <cool_screen_name90001@yahoo.com> writes:
> Is it possible to update the timezone part of
> timestamp fields in a single query? I have a bunch of
> values that are -06 I need changed to -07.

I suspect that you have a fundamental conceptual error.

You cannot "update the timezone" because the timezone is not part of the
stored value; it is part of the display operation.  Stored values for
timestamptz columns are always effectively in UTC.  When the value is
converted to a string for display, it is adjusted to your current local
timezone (per SET TIME ZONE) and that timezone is what's put on the
output.

So the basic answer is you don't change the data, you change your
TIME ZONE setting from -6 to -7 if that's what you want to see.

You might have an additional problem that the data was entered
incorrectly, and is one hour off from reality because you were
confused about time zones when you put it in.  In that case you'd
fix it with something like
    UPDATE tab SET col = col + '1 hour'::interval;

            regards, tom lane

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

Предыдущее
От: "Roderick A. Anderson"
Дата:
Сообщение: Re: Groups vs. Roles
Следующее
От: Ryan Mahoney
Дата:
Сообщение: max_fsm_pages