Search Postgresql Archives

Re: Intervals and ISO 8601 duration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



(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@xxxxxxxxx> 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.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux