Re: problem with selects based on dates

From: "J(dot)H(dot)M(dot) Dassen (Ray)" <jdassen(at)cistron(dot)nl>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: problem with selects based on dates
Date: 2001-09-06 09:00:10
Message-ID: slrn9peeoq.u6.jdassen@odin.cistron-office.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Mike Withers <M(dot)withers(at)uws(dot)edu(dot)au> wrote:
> db2001=# SELECT * FROM emp WHERE hiredate > 1981-01-01;
^^^^^^^^^^

> It is not clear to me why in the last query the 1980-12-17 hiredate record
> is selected as well.

There are no quotes around what you intend to be the date. Thus it is
evaluated as an expression, resulting in 1979. Try
SELECT * FROM emp WHERE hiredate > '1981-01-01';

HTH,
Ray
--
sendmail.cf does not resemble line noise. It resembles the result of
somebody banging his head on the keyboard. Anybody who has worked with it
will understand why.
Seth Breidbart in <8db6uj$67j$1(at)panix2(dot)panix(dot)com>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Colin 't Hart 2001-09-06 10:01:10 Re: PHP performance problems with postgres
Previous Message Martijn van Oosterhout 2001-09-06 08:50:44 Re: problem with selects based on dates