Re: Adding seconds to a time

Поиск
Список
Период
Сортировка
От Lew
Тема Re: Adding seconds to a time
Дата
Msg-id i6ucb0$nha$1@news.albasani.net
обсуждение исходный текст
Ответ на Re: Adding seconds to a time  ("Jean-Yves F. Barbier" <12ukwn@gmail.com>)
Ответы Re: Adding seconds to a time  ("Jean-Yves F. Barbier" <12ukwn@gmail.com>)
Список pgsql-novice
(Top-posting corrected.)

Rob Richardson wrote:
>> And, of course, as soon as I post the question I find the answer,
>> through a more intelligent search:
>>
>> Multiply the number by a standard interval:
>>      select N * '1 second'::interval

Jean-Yves F. Barbier wrote:
 > Be careful though, there might be a '+1x' shift:
 > SELECT now();                       =>  2010-09-15 15:39:02.838245+02
 > see:
 > SELECT now() + '1 month'::interval; =>  2010-10-15 15:39:27.518034+02
 >
 > I guess that is an SQL rule, but it is not "legally" correct, when you
 > calculate a contract termination date for example (which should be
 > 2010-10-14.)

Of course it's legally correct.  One month after September 15 is October 15 by
anyone's definition.

The contract termination issue is not due to miscalculation of "plus one
month" but to mistaken inclusion of the +1 month date within the contract
period.  The contract needs to be understood as "from date X through but not
including X + '1 month'::interval'".  The date X + '1 month'::interval still
is what it is, e.g., October 15 in your example.

--
Lew

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

Предыдущее
От: Richard Broersma
Дата:
Сообщение: Re: Unable to use VIEWS (Ok button remains shaded)
Следующее
От: Salil Wadnerkar
Дата:
Сообщение: Re: transaction is read-only error