Re: Select data for current week only

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Re: Select data for current week only
Дата
Msg-id h76lu6$lqr$1@ger.gmane.org
обсуждение исходный текст
Ответ на Re: Select data for current week only  (Sam Mason <sam@samason.me.uk>)
Список pgsql-general
Sam Mason wrote on 27.08.2009 21:06:
>
> The OP leaves it somewhat open, but wouldn't date_trunc be better here?
>
> Otherwise you'll end up getting values for other years as well as the
> current one.

Good point, I didn't think of that :)

As an alternative, one could explicitely add the year into the where condition:

SELECT *
FROM the_table
WHERE extract(week from the_date_column) = extract(date from current_date)
AND extract(year from the_date_column) = extract(year from current_date);

but your solution is definitely more elegant ...

Thomas



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

Предыдущее
От: Sam Mason
Дата:
Сообщение: Re: Select data for current week only
Следующее
От: Thomas Kellerer
Дата:
Сообщение: Getting the column to a which a sequence belongs.