> You are proposing a mathematical operation that looks exact but
> has a fuzzy result and the reason it is fuzzy is that you are trying
> shortcut the process of deciding what rule to apply.
But it is a fuzzy process. Three months is not the same number of days
from January-March as it is from June-August. For that matter, March
7th 2002 has 25 hours in California, but only 24 hours in Arizona.
While an ideal database would allow accounting for all of these rules,
it is practically impossible.
> You mentioned calculating the number of 2-week intervals in an
> column: if you need to do this, the column should not be defined as
> TO MONTH but as DAY (of course, PostgreSQL hasn't yet implemented
> subtypes of INTERVAL). If you *have* to do it with a YEAR TO MONTH
> column, you have implicitly defined a local rule that averages out
> difference in month lengths, because in a YEAR-MONTH interval, you
> know how long a year or a month is.
Precisely. You have to estimate. And the database system should allow
for either implicit or explicit estimation.
>You gave the example
> interval_round('7 months','days') / '3 days' = 70
> which seems to assume that a month is 30 days. On a different basis
> result would be 365.2425 * 7 / 12 / 3 = 71.019375 or 365 * 7 / 12 /
> = 70.972222. Both of those round to 71 days. Your 7 months interval
> anything from 209 to 213 days depending on which months it includes,
> which is unknowable without a context.
> So if you define interval_round() you must also include some means of
> configuring what rule to use, because that is not necessarily going
> be the same in every organisation. It might not even be the same
> between different applications in one organisation.
This makes sense but it would be harder to implement. I suppose it all
depends on what programmmers have time, yes? I take it you're
interval_round(interval_value, interval_unit, interval_rule) ?
Given that you seem to have given this some thought as well, I'd like
to hear your ideas on a workable solution for interval math. Also, I
notice that you did not comment on my proposal that we allow interval
multiplication only by integers. Does that mean you agree?
In response to
pgsql-sql by date
|Next:||From: Jean-Luc Lachance||Date: 2002-05-20 16:07:37|
|Subject: Re: count(boolean)|
|Previous:||From: Masaru Sugawara||Date: 2002-05-20 15:31:05|
|Subject: Re: Using LASTOID in one query|