pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Allan Engelhardt <allane@cybaea.com>
Cc: Josh Berkus <josh@agliodbs.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Re: Data type confusion
Date: Sun, 05 Aug 2001 19:19:17 -0400
Message-ID: <7212.997053557@sss.pgh.pa.us> (raw)
In-Reply-To: <3B6DC695.599C2571@cybaea.com>
References: <web-97089@davinci.ethosmedia.com>
	<3B6DC695.599C2571@cybaea.com>

Allan Engelhardt <allane@cybaea.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



view thread (19+ messages)  latest in thread

Message-ID: <7212.997053557@sss.pgh.pa.us>
Permalink:  ../7212.997053557@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/7212.997053557@sss.pgh.pa.us

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, allane@cybaea.com, josh@agliodbs.com
  Subject: Re: Re: Data type confusion
  In-Reply-To: <7212.997053557@sss.pgh.pa.us>

* 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