Re: Intervals and ISO 8601 duration

Поиск
Список
Период
Сортировка
От Ken Tanzer
Тема Re: Intervals and ISO 8601 duration
Дата
Msg-id CAD3a31UHFVx_GMaf6zC1oVzJJjafchmHcKLO5UU=s3jhGa-+PQ@mail.gmail.com
обсуждение исходный текст
Ответ на Intervals and ISO 8601 duration  (Sebastien Flaesch <sebastien.flaesch@4js.com>)
Список pgsql-general
(resending--Martin didn't realize you hadn't sent to the list too.)

On Fri, Jan 13, 2023 at 2:28 PM Martin L. Buchanan <martinlbuchanan@gmail.com> wrote:
Dear Ken:

You can extract individual subfields of interval as described here:



Hi Martin.  I don't think that really gets at what's actually being stored.  For example, look at a 2-year interval.  Tom says they are being represented internally as Months, Days and Microseconds.  But if you use extract it does not report anything for these values, because for example months which might be 24 internally is being reported as 0 because years is reported as 2:

SELECT EXTRACT(YEARS FROM '2 years'::interval) AS years, EXTRACT(MONTHS FROM '2 years'::interval) AS months,  EXTRACT(DAYS FROM '2 years'::interval) AS days, EXTRACT(MICROSECONDS FROM '2 years'::interval) AS seconds;

 years | months | days | seconds
-------+--------+------+---------
     2 |      0 |    0 |       0


(1 row)


--
AGENCY Software  
A Free Software data system
By and for non-profits
(253) 245-3801

learn more about AGENCY or
follow the discussion.


--
AGENCY Software  
A Free Software data system
By and for non-profits
(253) 245-3801

learn more about AGENCY or
follow the discussion.

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

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: Intervals and ISO 8601 duration
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Intervals and ISO 8601 duration