From: PG Doc comments form <noreply@postgresql.org>
To: pgsql-docs@lists.postgresql.org
Cc: mdriyazathcse@gmail.com
Subject: Issue with interval calculation when adding 1 year to a non-leap year
Date: Fri, 08 Mar 2024 07:57:27 +0000
Message-ID: <170988464798.644.7130288736118645836@wrigleys.postgresql.org> (raw)
The following documentation comment has been logged on the website:
Page: https://www.postgresql.org/docs/16/functions-datetime.html
Description:
Dear PostgreSQL Developers,
I have encountered a potential issue with the interval calculation when
adding 1 year to a non-leap year. The behavior observed is that when adding
1 year to a date in a non-leap year such as 2023, the resulting date is
incorrectly set to February 28th instead of February 29th in the following
leap year, which should be 2024.
This behavior is inconsistent with the expected behavior, as it does not
account for leap years when performing date arithmetic using intervals.
Please find below a sample query illustrating the issue:
SELECT ('2023-02-28 23:59:59')::timestamp + INTERVAL '1 year';
Expected result: '2024-02-29 23:59:59'
Actual result: '2024-02-28 23:59:59'
This issue could potentially impact applications relying on accurate date
arithmetic, particularly in scenarios involving financial calculations or
date projections.
Thank you for your attention to this matter.
Sincerely,
Mohamed Riyazath
mdriyazathcse@gmail.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-docs@postgresql.org
Cc: noreply@postgresql.org, pgsql-docs@lists.postgresql.org, mdriyazathcse@gmail.com
Subject: Re: Issue with interval calculation when adding 1 year to a non-leap year
In-Reply-To: <170988464798.644.7130288736118645836@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox