Re: BUG #5227: please add a divide operator for intervals

From: Michał Pasternak <michal(dot)dtz(at)gmail(dot)com>
To: "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #5227: please add a divide operator for intervals
Date: 2009-12-03 01:36:28
Message-ID: 4b17161c.23a0100a.2612.ffffefba@mx.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

1 month / 1 day equals 30.

-----Original Message-----
From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
Sent: Thursday, December 03, 2009 12:46 AM
To: Michal Pasternak
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: [BUGS] BUG #5227: please add a divide operator for intervals

"Michal Pasternak" <michal(dot)dtz(at)gmail(dot)com> writes:
> Please add a divide operator for INTERVAL type, if possible.

Given that intervals have multiple subfields, it's far from obvious
what division should mean. What is '1 month' / '1 day'?

> db=# SELECT EXTRACT(EPOCH FROM '15 seconds'::INTERVAL) / EXTRACT(EPOCH
FROM
> '15 seconds'::INTERVAL);

If that's the behavior you want, you already have a way to do it
(and you could wrap that up in a user-defined operator if you chose).
It loses quite a lot of information though, so I doubt we'd want
to enshrine it as the standard definition.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message John R Pierce 2009-12-03 02:35:05 Re: BUG #5227: please add a divide operator for intervals
Previous Message Tom Lane 2009-12-02 23:45:31 Re: BUG #5227: please add a divide operator for intervals