RE: [GENERAL] SELECT Date

Поиск
Список
Период
Сортировка
От Jackson, DeJuan
Тема RE: [GENERAL] SELECT Date
Дата
Msg-id F10BB1FAF801D111829B0060971D839F461A29@cpsmail
обсуждение исходный текст
Ответы RE: [GENERAL] SELECT Date  (Andy Lewis <alewis@mpsi.net>)
Список pgsql-general
> >I have a table with somedate defined as date.
> >
> >I want to select all rows that are from todays date back to 7 days
> >ago. Or in this case 10-1-1998.
>
> Use the function age() somewhat like this:
>
> select * from sometable
> where date_part( 'epoch' , age( 'now', somedate ) ) > 604800
>
> The 'epoch' date part is the total number of seconds between the two
> dates.
> For other variations, see:
>
> http://www/postgresql.org/docs/user/functions1574.htm
>
Why don't you just use between:
select * from sometable
where somedate between now()::date and (now()::datetime - '@ 7
days'::timespan)::date;
    -DEJ

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

Предыдущее
От: La Mancha de la Calabaza que Ladra
Дата:
Сообщение: ...
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: [GENERAL] select * from table where oid = number;