Select last week

Поиск
Список
Период
Сортировка
От Bill Moseley
Тема Select last week
Дата
Msg-id 20090606140355.GA15026@hank.org
обсуждение исходный текст
Список pgsql-general
I'm looking at ways to select rows with a timestamp column of "last
week" relative to the current server time.

In 8.3 there's "isoyear" so is this a good approach?

    extract( isoyear from foo_time )
        = extract( isoyear from now() - interval '1 week' )

    AND

    extract( week from foo_time )
        = extract( week from now() - interval '1 week' )

What about before isoyear was available in Postgresql?

Find the week and then add a week for the range?


    date_trunc( 'second', foo_time ) BETWEEN
        date_trunc( 'week', now() - interval '1 week' )
    AND
        date_trunc( 'week', now() - interval '1 week' )
            + interval '1 week' - interval '1 second'

Is there a better approach?



--
Bill Moseley
moseley@hank.org
Sent from my iMutt


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

Предыдущее
От: Raymond O'Donnell
Дата:
Сообщение: Re: How to store text files in the postgresql?
Следующее
От: "Nykolyn, Andrew P (AS)"
Дата:
Сообщение: Upgrade from Postgres 8.2.4 to 8.3.5