Re: date ranges in where

Поиск
Список
Период
Сортировка
От Raymond O'Donnell
Тема Re: date ranges in where
Дата
Msg-id 4A01FE3B.5090605@iol.ie
обсуждение исходный текст
Ответ на date ranges in where  (Miguel Miranda <miguel.mirandag@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Miguel Miranda
Дата:
Сообщение: date ranges in where
Следующее
От: Erik Jones
Дата:
Сообщение: Re: date ranges in where