Re: query by partial timestamp - Mailing list pgsql-general

From Michael Nolan
Subject Re: query by partial timestamp
Date
Msg-id CAOzAquK1PAXWFu7ViL2R0miDxw=bcP14K4iufA4iufBtS33CXQ@mail.gmail.com
Whole thread Raw
In response to Re: query by partial timestamp  (Gavan Schneider <pg-gts@snkmail.com>)
Responses Re: query by partial timestamp  (Michael Nolan <htfoot@gmail.com>)
Re: query by partial timestamp  (Gavan Schneider <pg-gts@snkmail.com>)
List pgsql-general
On 1/8/13, Gavan Schneider <pg-gts@snkmail.com> wrote:

> 2.  SELECT ... WHERE
>          '2011-01-01'::TIMESTAMP <= col_of_type_timestamp
>      AND                            col_of_type_timestamp <=
> '2011-12-31'::TIMESTAMP;

This won't  quite work, because '2011-12-31'::TIMESTAMP
is the same as 2011-12-31 00:00:00.00000
so records timestamped later in the day on the 31st would not get selected

  SELECT ... WHERE
         '2011-01-01'::TIMESTAMP <= col_of_type_timestamp
     AND                 col_of_type_timestamp < '2012-01:01'::TIMESTAMP;

would get all records with a 2011 timestamp.
--
Mike Nolan


pgsql-general by date:

Previous
From: Honza Horak
Date:
Subject: PostgreSQL hackfest @ Developer Conference 2013, Brno, CZ
Next
From: Michael Nolan
Date:
Subject: Re: query by partial timestamp