Re: BUG #18348: Inconsistency with EXTRACT([field] from INTERVAL);

David Rowley <dgrowleyml@gmail.com>

From: David Rowley <dgrowleyml@gmail.com>
To: work.michael.2956@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2024-02-16T13:02:20Z
Lists: pgsql-bugs, pgsql-hackers
On Sat, 17 Feb 2024 at 01:27, PG Bug reporting form
<noreply@postgresql.org> wrote:
> tpch=# select extract(week from interval '3 weeks');
> ERROR:  interval units "week" not supported
>
> In the documentation it's mentioned that 'week' is an ISO 8601 week, so it
> makes sense why it's not applicable to INTERVAL, which is the same for
> isoyear. However, the field is named week and not isoweek, so I expect it to
> work like the `select extract(year from interval '3 years');` does.
> Moreover, the documentation does not mention that the field cannot be
> extracted from INTERVAL, like it does for isoyear:
> https://www.postgresql.org/docs/current/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT

Maybe that table should specify which type(s) each of the items listed
is applicable to. Seems better than mentioning which types they're not
applicable to.

David



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix extraction of week and quarter fields from intervals.

  2. Doc: improve explanation of type interval, especially extract().