Re: BUG #14850: Implement optinal additinal parameter for 'justify' date/time function

From: Arthur Zakirov <a(dot)zakirov(at)postgrespro(dot)ru>
To: kes-kes(at)yandex(dot)ru
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #14850: Implement optinal additinal parameter for 'justify' date/time function
Date: 2017-10-12 09:15:43
Message-ID: 20171012091542.GA8159@zakirov.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-general pgsql-hackers

On Wed, Oct 11, 2017 at 10:35:12AM +0000, kes-kes(at)yandex(dot)ru wrote:
>
> >Adjust interval so 30-day time periods are represented as months
>
> https://www.postgresql.org/docs/9.6/static/functions-datetime.html
>

Yes, it seems that it is because timestamp operations return '29 days':

=# SELECT timestamp '2016-01-31' +interval '1 month' -timestamp '2016-01-31';
?column?
----------
29 days

You can also try the following, maybe it is appropriate for you:

=# SELECT timestamp '2016-01-31' -timestamp '2016-01-31' +interval '1 month';
?column?
----------
1 mon

=# SELECT extract( month from justify_days( timestamp '2016-01-31'
-timestamp '2016-01-31' +interval '1 month') );
date_part
-----------
1

--
Arthur Zakirov
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message KES 2017-10-12 10:01:06 Re: BUG #14850: Implement optinal additinal parameter for 'justify' date/time function
Previous Message KES 2017-10-12 08:00:54 Fwd: [BUGS] BUG #14850: Implement optinal additinal parameter for 'justify' date/time function

Browse pgsql-general by date

  From Date Subject
Next Message Durumdara 2017-10-12 09:35:24 Restore LargeObjects on different server
Previous Message KES 2017-10-12 08:00:54 Fwd: [BUGS] BUG #14850: Implement optinal additinal parameter for 'justify' date/time function

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2017-10-12 09:31:29 Re: PoC plpgsql - possibility to force custom or generic plan
Previous Message Alvaro Herrera 2017-10-12 09:05:50 Re: Discussion on missing optimizations