Michal Lijowski <michal@cvu.wustl.edu> writes:
> I made a database and I would like to select entries
> which have data not equal to the specified date.
> RabStudies=> SELECT RabNo, ImplantDate, Comments FROM RabStudiesInfo
> where implantdate <> 0001-01-01;
What you have on the right there is an integer expression with a value
of -1 (one minus one minus one). You need to put quotes around it to
make it be treated as a date constant:
where implantdate <> '0001-01-01';
Just FYI, pretty much any non-numeric literal has to be quoted as if it
were a string. Postgres usually infers the specific type from context
--- here, since you're comparing to a column of type date, the
unspecified-type literal will be presumed to be a date. You can add an
explicit cast if you need to force the literal to be converted to a
specific datatype.
where implantdate <> cast('0001-01-01' as date);
where implantdate <> '0001-01-01'::date;
The CAST syntax is SQL-standard, the :: syntax is a Postgres-ism.
regards, tom lane