Re: [SQL] Re: Data type confusion

2001-08-06 Thread Josh Berkus
Tom, > > Hmmm ... does this mean that I couldn't divide '1 year' by '1 > week'? > > That's exactly what it says. If that's the case, we'd need to create some sort of function to specify the time unit to output timestamp operation into: to_weeks(current_timestamp - hire_date) / '2 weeks' ... o

Re: [SQL] Re: Data type confusion

2001-08-06 Thread Tom Lane
"Josh Berkus" <[EMAIL PROTECTED]> writes: > Hmmm ... does this mean that I couldn't divide '1 year' by '1 week'? That's exactly what it says. regards, tom lane ---(end of broadcast)--- TIP 3: if posting/reading through Usen

Re: [SQL] Re: Data type confusion

2001-08-06 Thread Josh Berkus
Tom, > Curiously enough, ANSI doesn't define an INTERVAL-divided-by-INTERVAL > function either. Also, it rather looks like ANSI adopted the > position > Peter E. expressed: > > Year-month intervals are mutually comparable only with other > year- > month intervals. [...] >

Re: [SQL] Re: Data type confusion

2001-08-06 Thread Tom Lane
"Josh Berkus" <[EMAIL PROTECTED]> writes: > I don't want to go through a bunch of non-ANSI SQL-compliant conversion > functions to do it. Especially not as this is just what the ANSI SQL > data type and operator specs are designed to support. Curiously enough, ANSI doesn't define an INTERVAL-div

Re: [SQL] Re: Data type confusion

2001-08-06 Thread Josh Berkus
Allan, > I see now what you are trying to do. It sort of makes sense, but I'm > still really reluctant to give (semantic or otherwise) meaning to > "yesterday divided by tomorrow" . I don't agree. Consider, for example, this statement: '30 weeks ago'::INTERVAL / '2 weeks'::INTERVAL = -15

Re: [SQL] Re: Data type confusion

2001-08-06 Thread Tom Lane
"Josh Berkus" <[EMAIL PROTECTED]> writes: > Peter is absolutely correct here. '1 year'::INTERVAL - '1 > day'::INTERVAL is '364 days'::INTERVAL most of the time. However, on > leap years it is '365 days'. Au contraire, it is always '1 year - 1 day'::INTERVAL. That is a two-part interval value a

Re: [SQL] Re: Data type confusion

2001-08-06 Thread Josh Berkus
Folks, Wow. Talk about asking dangerous questions ... > For a 3-part (month/day/second) interval, I think the preferable rule > for timestamp subtraction is to use the largest symbolic component > possible, ie, use the largest number of months/years you can, then > use the largest number of day

Re: [SQL] Re: Data type confusion

2001-08-05 Thread Tom Lane
Peter Eisentraut <[EMAIL PROTECTED]> writes: > but > '2001-08-06 03:03:03' - '2000-08-06 03:03:00' = '365 days 3 seconds' > '2000-08-06 03:03:03' - '1999-08-06 03:03:00' = '366 days 3 seconds' What I said was that timestamp plus or minus interval is well-defined (when "interval" is a multi-part

Re: [SQL] Re: Data type confusion

2001-08-05 Thread Peter Eisentraut
Tom Lane writes: > I don't agree --- five years and three minutes is perfectly meaningful. > There are only certain things you can validly do with it, however, and > scaling by a floating-point number isn't one of them, because fractional > months aren't well-defined. But you can, for example, a

Re: [SQL] Re: Data type confusion

2001-08-05 Thread Tom Lane
Peter Eisentraut <[EMAIL PROTECTED]> writes: > One day we will have to accept the fact that months and seconds must not > be mixed, period. You can have year/month intervals or > day/hour/minute/second intervals, not a combination. An interval of '5 > years 3 minutes' has no meaning with the nat

Re: [SQL] Re: Data type confusion

2001-08-05 Thread Peter Eisentraut
Tom Lane writes: > It is kinda bogus, given the underlying semantics of intervals > (integer months plus float seconds). > 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. One day we

Re: [SQL] Re: Data type confusion

2001-08-05 Thread Tom Lane
Allan Engelhardt <[EMAIL PROTECTED]> 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 o