Re: search for partial dates

Поиск
Список
Период
Сортировка
От Andy Colson
Тема Re: search for partial dates
Дата
Msg-id 4A317918.7050105@squeakycode.net
обсуждение исходный текст
Ответ на search for partial dates  ("James B. Byrne" <byrnejb@harte-lyne.ca>)
Ответы Re: search for partial dates  ("James B. Byrne" <byrnejb@harte-lyne.ca>)
Список pgsql-general
James B. Byrne wrote:
> Given a datetime column, not null, is there a single syntax that
> permits searching for all dates in a given year, year+month, and
> year+month+day such that a single parameterised query can handle all
> three circumstances?
>

That's a little vague, so how about:

select * from somethine where (extract(year from idate) = $1) or
(extract(year from idate) = $2 and extract(month from idate) = $3) or
(extract(year from idate) = $4 and extract(month from idate) = $5 and
extract(day from idate) = $6)

-Andy

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

Предыдущее
От: Scott Marlowe
Дата:
Сообщение: Re: help with data recovery from injected UPDATE
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: Postgres auditing features