From: | KES <kes-kes(at)yandex(dot)ru> |
---|---|
To: | Arthur Zakirov <a(dot)zakirov(at)postgrespro(dot)ru> |
Cc: | "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: BUG #14850: Implement optinal additinal parameter for 'justify' date/time function |
Date: | 2017-10-12 10:01:06 |
Message-ID: | 207501507802466@web37j.yandex.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs pgsql-general pgsql-hackers |
No. Your example work only for those values.
Try this:
SELECT extract( month from justify_days( timestamp '2016-02-29' -timestamp '2016-01-31') );
date_part
-----------
0
(1 row)
select extract( month from justify_days( timestamp '2016-02-29' -timestamp '2016-01-31'), timestamp '2016-01-31' );
date_part
-----------
1
(1 row)
12.10.2017, 12:15, "Arthur Zakirov" <a(dot)zakirov(at)postgrespro(dot)ru>:
> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Heikki Linnakangas | 2017-10-12 11:59:12 | Improper const-evaluation of HAVING with grouping sets and subquery pullup |
Previous Message | Arthur Zakirov | 2017-10-12 09:15:43 | Re: BUG #14850: Implement optinal additinal parameter for 'justify' date/time function |
From | Date | Subject | |
---|---|---|---|
Next Message | Durumdara | 2017-10-12 10:41:49 | Re: Restore LargeObjects on different server |
Previous Message | Durumdara | 2017-10-12 09:35:24 | Restore LargeObjects on different server |
From | Date | Subject | |
---|---|---|---|
Next Message | tushar | 2017-10-12 10:03:43 | Query started showing wrong result after Ctrl+c |
Previous Message | Pavel Stehule | 2017-10-12 09:31:29 | Re: PoC plpgsql - possibility to force custom or generic plan |