Re: problem with selects based on dates - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: problem with selects based on dates
Date
Msg-id 20010906185044.B11097@svana.org
Whole thread Raw
In response to problem with selects based on dates  (Mike Withers <M.withers@uws.edu.au>)
List pgsql-general
On Thu, Sep 06, 2001 at 05:15:50PM +1000, Mike Withers wrote:
> Hi everyone
>
> I have a problem with SELECTs using dates and WHERE.
> Some examples:
>
> db2001=# SELECT * FROM emp WHERE hiredate > 1981;

1981 is not a valid date.

> db2001=# SELECT * FROM emp WHERE hiredate > 1981-01-01;

1981-01-01 = 1979 which is also not a valid date.

Try putting quotes around the date, like:

SELECT * FROM emp WHERE hiredate > '1981-01-01';

You'll find it works much better.
--
Martijn van Oosterhout <kleptog@svana.org>
http://svana.org/kleptog/
> Magnetism, electricity and motion are like a three-for-two special offer:
> if you have two of them, the third one comes free.

pgsql-general by date:

Previous
From: "Oliver Elphick"
Date:
Subject: Re: FOREIGN KEY: MATCH FULL
Next
From: "J.H.M. Dassen (Ray)"
Date:
Subject: Re: problem with selects based on dates