Re: Re: Data type confusion

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Allan Engelhardt <allane(at)cybaea(dot)com>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Re: Data type confusion
Date: 2001-08-05 23:19:17
Message-ID: 7212.997053557@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Allan Engelhardt <allane(at)cybaea(dot)com> writes:
> I don't think it makes conceptual sense to divide intervals....

It is kinda bogus, given the underlying semantics of intervals
(integer months plus float seconds). The problem already arises
for the existing interval * float8 and interval / float8 operators,
though, so it'd be easy enough to make an interval / interval operator
that is consistent with them. What those operators do is to convert
any fractional-month result into seconds at an arbitrary conversion
factor of 30 days to the month. For example, consider

regression=# select '5 months 9 days'::interval;
?column?
---------------
5 mons 9 days
(1 row)

regression=# select '5 months 9 days'::interval * 0.5;
?column?
----------------------
2 mons 19 days 12:00
(1 row)

The initial product is effectively 2.5 months plus 4.5 days,
and then we translate the .5 months into 15 days.

This is pretty grotty, and AFAIK not documented anywhere --- I found it
out by looking at the C code for these operators. But I'm not sure
how to do better.

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Peter Eisentraut 2001-08-06 00:00:03 Re: Re: Data type confusion
Previous Message Josh Berkus 2001-08-05 23:00:27 Re: Data type confusion