Re: now() and interval

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: now() and interval
Дата
Msg-id 9555.1017849834@sss.pgh.pa.us
обсуждение исходный текст
Ответ на now() and interval  ("Travis Hoyt" <thoyt@npc.net>)
Список pgsql-novice
"Travis Hoyt" <thoyt@npc.net> writes:
> Just curious, why does this date manipulation return the incorrect value
> based on the order of the operation?
> mydb=> select interval '1 month' + now();
> mydb=> select now() + interval '1 month';

Looking in pg_operator (or "\do +" in psql) shows that there is a
"timestamp plus interval" operator, but no "interval plus timestamp"
operator.  So in the first case the system will pick one of the
available operators and then coerce your values to the appropriate
input datatypes.  I'm too lazy to work out which pair of datatypes is
being selected, but a good bet is that the timestamp from now() is being
cut down to a date.

            regards, tom lane

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

Предыдущее
От: "Travis Hoyt"
Дата:
Сообщение: now() and interval
Следующее
От: "Ken Gerdes"
Дата:
Сообщение: finding out about databases and tables