Re: help: now() + N is now failing! - Mailing list pgsql-novice

From Stephan Szabo
Subject Re: help: now() + N is now failing!
Date
Msg-id 20030729080443.C87665-100000@megazone.bigpanda.com
Whole thread Raw
In response to Re: help: now() + N is now failing!  (Dmitry Tkach <dmitry@openratings.com>)
Responses Re: help: now() + N is now failing!  (Dmitry Tkach <dmitry@openratings.com>)
List pgsql-novice
On Tue, 29 Jul 2003, Dmitry Tkach wrote:

> Yeah... Looks weird.
> For some reason, even  date_pli(now(), 2) doesn't work any more - you
> have to do date_pli(now()::date,2)
> I guess, the now()+2 has the same problem - for some reason, it fails to
> coerce timestamptz into date automatically :-(
> Why is that? There is only one function called date_pli(), and there is
> an unambigous conversion date(timestamptz)... Why does it now force the
> user to cast explicitly???

It's not an implicit cast any longer (see pg_cast).  Implicit casts often
result in unexpected behavior.

For example, what should now()+2 mean?  Converting to date and adding two
days is fairly wierd behavior, I'd much more expect it to say add 2
seconds or error.  now() + interval '2 days' or cast(now() as date)+2 both
express the intent of adding 2 days much better.


pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: any idea regarding this error?
Next
From: Tom Lane
Date:
Subject: Re: help: now() + N is now failing!