Re: Comparing dates

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: John Velman <velman(at)cox(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Comparing dates
Date: 2003-09-04 02:29:47
Message-ID: 20030904022947.GB6418@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Sep 02, 2003 at 04:09:00PM -0700, John Velman wrote:
> My date setting is ISO with US conventions, and output from a select
> is in the form yyyy-mm-dd (2002-01-18, for example.
>
> When I do a select such as
>
> SELECT * FROM table WHERE date BETWEEN '2001-12-28' AND '2002-01-28'
>
> It misses the entry with date '2002-01-28' (which does exist!).

So, your date column is actually a timestamp? Cast it to date first and
see if it works, e.g.

SELECT * FROM table WHERE date::date BETWEEN '2001-12-28' AND '2002-01-28'

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"La principal característica humana es la tontería"
(Augusto Monterroso)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2003-09-04 02:40:11 Re: Using oids
Previous Message Joseph Hepburne Healy 2003-09-04 02:24:54 Re: What is the good equivalent for ENUM ?