Wish: support "quarter" in Interval

From: Richard Neill <rn214(at)cam(dot)ac(dot)uk>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Wish: support "quarter" in Interval
Date: 2021-03-16 23:38:02
Message-ID: 6b2a4293-6f88-8114-aa0f-d7becdaafbdf@cam.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello,

May I make a request that "Quarter" should be treated as a valid
Interval (as a synonym for "3 months"), to be consistent with other date
functions that allow it, such as date_trunc() and extract() ?

#1. 'quarter' is valid for date_trunc() and extract()

SELECT date_trunc ('quarter', now());

date_trunc
------------------------
2021-01-01 00:00:00+00

SELECT EXTRACT ('quarter' FROM now());

date_part
-----------
1

#2. But, 'quarter' is invalid for interval

SELECT '1 quarter'::interval;
ERROR: invalid input syntax for type interval: "1 quarter"

I would expect it to give exactly the same result as for 3 months:

SELECT '3 months' :: interval;

interval
----------
3 mons

* As an aside: it might also be useful to support "half"
(which half of a year), or interval of 6 months,
and the interval of "fortnight" = 14 days.

I'm testing this on version 13.2:

SELECT version();

version
-------------------------------------------------------------------------
PostgreSQL 13.2 (Ubuntu 13.2-1) on x86_64-pc-linux-gnu, compiled by gcc
(Ubuntu 10.2.1-19ubuntu1) 10.2.1 20210206, 64-bit

Thank you very much for your consideration.

Richard

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2021-03-16 23:56:01 Re: BUG #16927: Postgres can`t access WAL files
Previous Message Michael Paquier 2021-03-16 22:30:00 Re: BUG #16927: Postgres can`t access WAL files