Re: Comparing dates - Mailing list pgsql-general

From Tom Lane
Subject Re: Comparing dates
Date
Msg-id 10559.1062648692@sss.pgh.pa.us
Whole thread Raw
In response to Comparing dates  ("John Velman" <velman@cox.net>)
List pgsql-general
"John Velman" <velman@cox.net> writes:
> 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!).

Uh, what exactly is the datatype of the "date" column?

> The only way I've been able to handle this, so far, is
> in this fashion:
> SELECT * FROM table WHERE
>     date BETWEEN 20011228 - .001 AND 20020128 + .001 ;

I think the odds that this does what you think it does are vanishingly
small :-(.  There's no date-vs-numeric comparison operator.  It's
probably getting interpreted as some bizarre textual comparison.

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Index not being used ?
Next
From: Tom Lane
Date:
Subject: Re: TCL trigger doesn't work after deleting a column