From: | Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com> |
---|---|
To: | "Martin L(dot) Buchanan" <martinlbuchanan(at)gmail(dot)com> |
Cc: | PG-General Mailing List <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Intervals and ISO 8601 duration |
Date: | 2023-01-13 22:47:53 |
Message-ID: | CAD3a31UHFVx_GMaf6zC1oVzJJjafchmHcKLO5UU=s3jhGa-+PQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)gmail(dot)com> wrote:
> Dear Ken:
>
> You can extract individual subfields of interval as described here:
>
>
> https://www.postgresql.org/docs/14/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT
>
>
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
>> *http://agency-software.org/ <http://agency-software.org/>*
>> *https://demo.agency-software.org/client
>> <https://demo.agency-software.org/client>*
>> ken(dot)tanzer(at)agency-software(dot)org
>> (253) 245-3801
>>
>> Subscribe to the mailing list
>> <agency-general-request(at)lists(dot)sourceforge(dot)net?body=subscribe> to
>> learn more about AGENCY or
>> follow the discussion.
>>
>
--
AGENCY Software
A Free Software data system
By and for non-profits
*http://agency-software.org/ <http://agency-software.org/>*
*https://demo.agency-software.org/client
<https://demo.agency-software.org/client>*
ken(dot)tanzer(at)agency-software(dot)org
(253) 245-3801
Subscribe to the mailing list
<agency-general-request(at)lists(dot)sourceforge(dot)net?body=subscribe> to
learn more about AGENCY or
follow the discussion.
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2023-01-13 22:49:28 | Re: Intervals and ISO 8601 duration |
Previous Message | Adrian Klaver | 2023-01-13 22:41:08 | Re: Intervals and ISO 8601 duration |