Re: Quick Date/Time Index Question

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Quick Date/Time Index Question
Дата
Msg-id 12016.1316730674@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Quick Date/Time Index Question  ("David Johnston" <polobo@yahoo.com>)
Список pgsql-general
"David Johnston" <polobo@yahoo.com> writes:
> I have a database field that stores a timestamp to second+ precision;
> however, I want to search against it only to day precision.  If I leave the
> field in second precision and try to "WHERE field BETWEEN date0 AND date0" I
> get no results (OK, fine) but then I cast the field to date "WHERE
> field::date BETWEEN date0 AND date0" and get the expected results.

Try "WHERE field BETWEEN date0 AND date0+1".  When comparing a date to a
timestamp, the date is considered to represent midnight of its day, so
you're testing for a zero-width range there.

            regards, tom lane

В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Replication between 64/32bit systems?
Следующее
От: Jeff Davis
Дата:
Сообщение: Re: Is 9.1 considered more stable/robust than 9.0.4 ?