Re: problem with selects based on dates

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Mike Withers <M(dot)withers(at)uws(dot)edu(dot)au>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: problem with selects based on dates
Date: 2001-09-06 08:50:44
Message-ID: 20010906185044.B11097@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)svana(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message J.H.M. Dassen (Ray) 2001-09-06 09:00:10 Re: problem with selects based on dates
Previous Message Rob Brown-Bayliss 2001-09-06 07:58:55 Primary keys and speed