Re: BUG #14313: justify interval bug

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: BUG #14313: justify interval bug
Дата
Msg-id CAM-w4HPQ5_RgEwJD6D6FF_Q147G20HV+0E8scCph4K3ziE-6eg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: BUG #14313: justify interval bug  (Vik Fearing <vik@2ndquadrant.fr>)
Список pgsql-bugs
On Mon, Sep 5, 2016 at 6:59 PM, Vik Fearing <vik@2ndquadrant.fr> wrote:
> Your timestamp subtraction results in 7305 days.  The justify_interval
> function, not knowing anything about where those days came from, will
> use 30 days per month, giving you the result you see.

Part of the story that's not apparent here is that intervals track
months and days
separately but don't track years separately. So the justified interval
internally is actually 243 months, 15 days, and 0 seconds. The "20
years" is just part of the output format.

The reason years aren't tracked separately is that they're always 12
months. So if you want an event in your calendar that occurs every
year on the same date you can add an interval like '12 months' to it
and it'll always add exactly a year and land on the same date
regardless of the number of days in the year.

--
greg

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

Предыдущее
От: Vik Fearing
Дата:
Сообщение: Re: BUG #14313: justify interval bug
Следующее
От: "Peterko"
Дата:
Сообщение: Re: [BUGS] BUG #14313: justify interval bug