Re: Inconsistant DOW...

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Inconsistant DOW...
Дата
Msg-id 29179.1088445899@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Inconsistant DOW...  (Richard Huxton <dev@archonet.com>)
Ответы Re: Inconsistant DOW...  ("W.B.Hill" <bill@hillzaa1.miniserver.com>)
Список pgsql-general
Richard Huxton <dev@archonet.com> writes:
> W.B.Hill wrote:
>> SELECT d+'45 days ago'::interval FROM test;
>>
>> Why the different times??? Why the times???

> At a guess, the date is being converted into a timestamp with timezone
> so you can add the interval to it.

Yeah, I think that will be the preferred conversion (and the fact that
the output shows a timezone offset is a dead giveaway ;-))

However there is also a timestamp-without-timezone plus interval
operator, so one good solution is to explicitly cast the date to
timestamp without tz and then add the interval.

Another and probably even better solution for this problem is to forget
timestamps and intervals, and use the date plus/minus integer operators
(ie, write "d - 45").  If you don't care about sub-day resolution there
is no reason to get into timestamps at all.

BTW, since 7.3 there has been a date-plus-interval operator yielding
timestamp without time zone, which I believe Lockhart added specifically
to avoid the unwanted promotion to timestamptz in this scenario.
So the third answer is to update to something less ancient than PG 7.2.

            regards, tom lane

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

Предыдущее
От: Együd Csaba
Дата:
Сообщение: Re: Performance problem on RH7.1
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Performance problem on RH7.1