Re: query for records based on date

Поиск
Список
Период
Сортировка
От Martín Marqués
Тема Re: query for records based on date
Дата
Msg-id 200502211742.55144.martin@bugs.unl.edu.ar
обсуждение исходный текст
Ответ на query for records based on date  ("Brandon Metcalf" <bmetcalf@nortel.com>)
Ответы Re: query for records based on date  ("Brandon Metcalf" <bmetcalf@nortel.com>)
Список pgsql-sql
El Lun 21 Feb 2005 17:00, Brandon Metcalf escribió:
> If I have a table with an attribute of type "timestamp without time
> zone", what is the best way to query that table for records that are
> older than, say, one week.
>
> I suppose I could get the current time in epoch seconds and the time of
> the attribute in the same, and select those records where the difference
> is greater than the number of seconds in a week.  Is there something
> easier like
>
>   SELECT * FROM table WHERE attribute IS OLDER THAN one week;

SELECT * FROM table WHERE attribute < (now()::DATE - 7)::TIMESTAMP;

-- 17:41:37 up 162 days,  7:36,  2 users,  load average: 0.11, 0.12, 0.08
-----------------------------------------------------------------
Martín Marqués        | select 'mmarques' || '@' || 'unl.edu.ar'
Centro de Telematica  |  DBA, Programador, Administrador            Universidad Nacional                 del Litoral
-----------------------------------------------------------------


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

Предыдущее
От: "Brandon Metcalf"
Дата:
Сообщение: query for records based on date
Следующее
От: "Brandon Metcalf"
Дата:
Сообщение: Re: query for records based on date