pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Neill <rn214@cam.ac.uk>
To: pgsql-bugs@lists.postgresql.org
Subject: Wish: support "quarter" in Interval
Date: Tue, 16 Mar 2021 23:38:02 +0000
Message-ID: <6b2a4293-6f88-8114-aa0f-d7becdaafbdf@cam.ac.uk> (raw)

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





Message-ID: <6b2a4293-6f88-8114-aa0f-d7becdaafbdf@cam.ac.uk>
Permalink:  ../6b2a4293-6f88-8114-aa0f-d7becdaafbdf@cam.ac.uk/
Also on:    postgresql.org/message-id/6b2a4293-6f88-8114-aa0f-d7becdaafbdf@cam.ac.uk

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: rn214@cam.ac.uk
  Subject: Re: Wish: support "quarter" in Interval
  In-Reply-To: <6b2a4293-6f88-8114-aa0f-d7becdaafbdf@cam.ac.uk>
  References: <6b2a4293-6f88-8114-aa0f-d7becdaafbdf@cam.ac.uk>

* 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