On Sun, 17 Aug 2003, Bruce Momjian wrote:

> Anyone have an idea on this one?
> 
> > It is maybe not bug, but I didn't find any warning about this behavior.
> > 
> > select current_date + 1;  -- ok
> > select 1 + current_date;  -- not
> > 
> > ERROR:  operator does not exist: integer + date
> > HINT:  No operator matches the given name and argument type(s). You may 
> > need to add explicit typecasts.

It's not a bug. The operator + has one definition of the type

   (date,integer) -> date

but there is no definition for

   (integer,date) -> date

Instead of integer one can also have an interval. So if you start with a
date you can add an interval to it. But if you start with a time interval
you can not add a date to it. What would it mean to add a date to
something? I have no idea. Well, that's the logic behind the current
behaviour.

It would of course not be difficult to add a definition of + with the
integer first and the date as the second argument. To me it's not much of
an improvement, but it's not for me to decide. The postgresql operator + 
is not the same as the mathematical operator + and it does not have the 
same properties.

-- 
/Dennis


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

Reply via email to