Re: BUG #6178: date_trunc : interval units "week" not supported contradicts documentation

Lists: pgsql-bugs
From: "Noah Hamerslough" <noah(at)pcc(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #6178: date_trunc : interval units "week" not supported contradicts documentation
Date: 2011-08-25 19:05:34
Message-ID: 201108251905.p7PJ5YLe075723@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 6178
Logged by: Noah Hamerslough
Email address: noah(at)pcc(dot)com
PostgreSQL version: 8.4
Operating system: Windows Vista
Description: date_trunc : interval units "week" not supported
contradicts documentation
Details:

http://www.postgresql.org/docs/8.4/static/functions-datetime.html#FUNCTIONS-
DATETIME-TRUNC

The documentation for date_trunc('field', source) lists 'week' in the as a
valid value for 'field' However, if the source is an interval, 'week' is not
supported.

select date_trunc('week', '1 month 15 days'::interval);

ERROR: interval units "week" not supported
SQL state: 0A000

Either 'week' should be supported or the documentation should be updated to
reflect that it is not.


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Noah Hamerslough <noah(at)pcc(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6178: date_trunc : interval units "week" not supported contradicts documentation
Date: 2012-08-15 20:50:08
Message-ID: 20120815205008.GO25473@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Thu, Aug 25, 2011 at 07:05:34PM +0000, Noah Hamerslough wrote:
>
> The following bug has been logged online:
>
> Bug reference: 6178
> Logged by: Noah Hamerslough
> Email address: noah(at)pcc(dot)com
> PostgreSQL version: 8.4
> Operating system: Windows Vista
> Description: date_trunc : interval units "week" not supported
> contradicts documentation
> Details:
>
> http://www.postgresql.org/docs/8.4/static/functions-datetime.html#FUNCTIONS-
> DATETIME-TRUNC
>
> The documentation for date_trunc('field', source) lists 'week' in the as a
> valid value for 'field' However, if the source is an interval, 'week' is not
> supported.
>
> select date_trunc('week', '1 month 15 days'::interval);
>
> ERROR: interval units "week" not supported
> SQL state: 0A000
>
> Either 'week' should be supported or the documentation should be updated to
> reflect that it is not.

Turns out the reason we don't support this is because there are usually
a fractional number of weeks in a month, so there is no good way to do
this for intervals. I have applied the attached patch to PG 9.3 which
will explain why this is not supported. I saw this as better than a
documentation mention.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

Attachment Content-Type Size
week.diff text/x-diff 1.0 KB