query for records based on date

From: "Brandon Metcalf" <bmetcalf(at)nortel(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: query for records based on date
Date: 2005-02-21 20:00:06
Message-ID: Pine.LNX.4.58L.0502211356580.24449@cash.rhiamet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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;

Thanks.

--
Brandon

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Mirko Zeibig 2005-02-21 20:36:17 Re: FW: Working with XML.
Previous Message Achilleus Mantzios 2005-02-21 16:44:04 Re: Timestamp with timezone question.