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 CBA9B8B9B49 for ; Mon, 21 Feb 2005 20:45:24 +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 45819-10 for ; Mon, 21 Feb 2005 20:45:22 +0000 (GMT) Received: from bugs.unl.edu.ar (bugs.unl.edu.ar [168.96.132.208]) by svr1.postgresql.org (Postfix) with ESMTP id 660F08B9B8A for ; Mon, 21 Feb 2005 20:45:22 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by bugs.unl.edu.ar (Postfix) with ESMTP id 7FC5F125B4; Mon, 21 Feb 2005 17:42:59 -0300 (ART) Received: from bugs.unl.edu.ar ([127.0.0.1]) by localhost (bugs [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 00836-04; Mon, 21 Feb 2005 17:42:59 -0300 (ART) Received: from localhost (localhost [127.0.0.1]) by bugs.unl.edu.ar (Postfix) with ESMTP id D77F9125B3; Mon, 21 Feb 2005 17:42:58 -0300 (ART) From: =?iso-8859-1?q?Mart=EDn_Marqu=E9s?= To: "Brandon Metcalf" Subject: Re: query for records based on date Date: Mon, 21 Feb 2005 17:42:54 -0300 User-Agent: KMail/1.7.1 Cc: pgsql-sql@postgresql.org References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200502211742.55144.martin@bugs.unl.edu.ar> X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at bugs.unl.edu.ar X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.198 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200502/227 X-Sequence-Number: 20338 El Lun 21 Feb 2005 17:00, Brandon Metcalf escribi=F3: > 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; =2D-=20 17:41:37 up 162 days, 7:36, 2 users, load average: 0.11, 0.12, 0.08 =2D---------------------------------------------------------------- Mart=EDn Marqu=E9s | select 'mmarques' || '@' || 'unl.edu.ar' Centro de Telematica | DBA, Programador, Administrador Universidad Nacional del Litoral =2D----------------------------------------------------------------