Re: BUG #3624: EXTRACT(QUARTER FROM INTERVAL) always returns 1
| От | Tom Lane |
|---|---|
| Тема | Re: BUG #3624: EXTRACT(QUARTER FROM INTERVAL) always returns 1 |
| Дата | |
| Msg-id | 28041.1190418313@sss.pgh.pa.us обсуждение |
| Ответ на | Re: BUG #3624: EXTRACT(QUARTER FROM INTERVAL) always returns 1 (Peter Eisentraut <peter_e@gmx.net>) |
| Список | pgsql-bugs |
Peter Eisentraut <peter_e@gmx.net> writes:
> SELECT EXTRACT(QUARTER FROM INTERVAL '200 days') gives 1. Why is that?
Because interval_part does
case DTK_QUARTER:
result = (tm->tm_mon / 3) + 1;
break;
Not sure that changing this is a good idea --- note that most of the
other cases also have blinders on about which fields of the struct pg_tm
to look at, and you'd need to make not-very-defensible assumptions about
conversion rates to incorporate other fields. Possibly the correct
answer is "you should apply justify_interval first, if that's the
behavior you want".
regression=# select justify_interval(INTERVAL '200 days');
justify_interval
------------------
6 mons 20 days
(1 row)
regression=# select extract(quarter from justify_interval(INTERVAL '200 days'));
date_part
-----------
3
(1 row)
regards, tom lane
В списке pgsql-bugs по дате отправления: