Re: date ranges in where - Mailing list pgsql-general

From Raymond O'Donnell
Subject Re: date ranges in where
Date
Msg-id 4A01FE3B.5090605@iol.ie
Whole thread Raw
In response to date ranges in where  (Miguel Miranda <miguel.mirandag@gmail.com>)
List pgsql-general
On 06/05/2009 22:12, Miguel Miranda wrote:
> Hi, what is the recommended way to select a range of dates?
>
> Lets say a have a table with a lastlogin (timestamp) column and i want
> toknow what users logged in for last time between 2009-05-01 and 2009-05-02?
>
> I know that a simple
>
> where lastlogin between '2009-05-01' and '2009-05-02' doesnt work beacuse it
> doesnt include who logged in 2009-05-02 15:30:00, etc...

Why not just include the time in the comparisons?

  ....between '2009-05-01 00:00'::timestamp
        and '2009-05-02 23:59:59'::timestamp

Ray.

------------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod@iol.ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------

pgsql-general by date:

Previous
From: Miguel Miranda
Date:
Subject: date ranges in where
Next
From: Erik Jones
Date:
Subject: Re: date ranges in where