X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 605AF8B9C95 for ; Mon, 21 Feb 2005 20:48:17 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49482-09 for ; Mon, 21 Feb 2005 20:48:14 +0000 (GMT) Received: from zcars04f.nortelnetworks.com (zcars04f.nortelnetworks.com [47.129.242.57]) by svr1.postgresql.org (Postfix) with ESMTP id 864D88B9C8A for ; Mon, 21 Feb 2005 20:48:14 +0000 (GMT) Received: from zrtps0m6.us.nortel.com (zrtps0m6.us.nortel.com [47.140.192.58]) by zcars04f.nortelnetworks.com (Switch-2.2.6/Switch-2.2.0) with ESMTP id j1LKmBK12910; Mon, 21 Feb 2005 15:48:11 -0500 (EST) Received: from cash.rhiamet.com (rhiamet.us.nortel.com [47.103.243.53]) by zrtps0m6.us.nortel.com (Switch-2.2.6/Switch-2.2.0) with ESMTP id j1LKm8H20938; Mon, 21 Feb 2005 15:48:08 -0500 (EST) Received: from cash.rhiamet.com (bmetcalf@localhost [127.0.0.1]) by cash.rhiamet.com (8.12.11/8.12.11/Debian-3) with ESMTP id j1LKm1oN031723; Mon, 21 Feb 2005 14:48:01 -0600 Received: from localhost (bmetcalf@localhost) by cash.rhiamet.com (8.12.11/8.12.11/Debian-3) with ESMTP id j1LKm0DM031719; Mon, 21 Feb 2005 14:48:01 -0600 X-Authentication-Warning: cash.rhiamet.com: bmetcalf owned process doing -bs Date: Mon, 21 Feb 2005 14:48:00 -0600 (CST) From: "Brandon Metcalf" X-X-Sender: bmetcalf@cash.rhiamet.com To: =?iso-8859-1?q?Mart=EDn_Marqu=E9s?= Cc: pgsql-sql@postgresql.org Subject: Re: query for records based on date In-Reply-To: <200502211742.55144.martin@bugs.unl.edu.ar> Message-ID: References: <200502211742.55144.martin@bugs.unl.edu.ar> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN Content-Transfer-Encoding: QUOTED-PRINTABLE X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200502/228 X-Sequence-Number: 20339 m =3D=3D martin@bugs.unl.edu.ar writes: m> El Lun 21 Feb 2005 17:00, Brandon Metcalf escribi=F3: m> > If I have a table with an attribute of type "timestamp without time m> > zone", what is the best way to query that table for records that are m> > older than, say, one week. m> > m> > I suppose I could get the current time in epoch seconds and the time = of m> > the attribute in the same, and select those records where the differe= nce m> > is greater than the number of seconds in a week. Is there something m> > easier like m> > m> > SELECT * FROM table WHERE attribute IS OLDER THAN one week; m> SELECT * FROM table WHERE attribute < (now()::DATE - 7)::TIMESTAMP; Thanks. --=20 Brandon