Re: what's wrong with my date comparison?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Tena Sakai" <tsakai(at)gallo(dot)ucsf(dot)edu>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: what's wrong with my date comparison?
Date: 2007-10-16 20:53:56
Message-ID: 23446.1192568036@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Tena Sakai" <tsakai(at)gallo(dot)ucsf(dot)edu> writes:
> I was missing quotes.
> It must have evaluated 2007-10-02 and used it as a
> numerical constant 1995.

Actually, what you got was a *textual* comparison between '1995' and
the timestamp converted to text, which makes even less sense.

FWIW, as of PG 8.3 you'll get an error:

regression=# select * from timestamp_tbl where d1 > 2007-10-02;
ERROR: operator does not exist: timestamp without time zone > integer
LINE 1: select * from timestamp_tbl where d1 > 2007-10-02;
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

We've seen too many people get burnt by variants of this problem...

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Sofer, Yuval 2007-10-17 07:09:35 when inserting to table, text type parameter become NULL (after big assignment to this parameter)
Previous Message Michael Glaesemann 2007-10-16 18:09:03 Re: what's wrong with my date comparison?