Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 644359FB8AE for ; Thu, 7 Jun 2007 15:12:10 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 88052-01-9 for ; Thu, 7 Jun 2007 15:12:06 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from exchange.g2switchworks.com (mail.g2switchworks.com [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 72A9F9FBBCB for ; Thu, 7 Jun 2007 15:12:06 -0300 (ADT) Received: from [10.10.1.37] ([10.10.1.37]) by exchange.g2switchworks.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 7 Jun 2007 13:12:00 -0500 Message-ID: <46684A70.4080903@g2switchworks.com> Date: Thu, 07 Jun 2007 13:12:00 -0500 From: Scott Marlowe User-Agent: Thunderbird 1.5.0.4 (X11/20060516) MIME-Version: 1.0 To: "Campbell, Lance" CC: Michael Glaesemann , pgsql-sql@postgresql.org Subject: Re: subtract a day from the NOW function References: <9938A77A-6E63-413D-8AC9-7CB741D075E6@seespotcode.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 07 Jun 2007 18:12:00.0273 (UTC) FILETIME=[57AB0010:01C7A92F] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/63 X-Sequence-Number: 28553 Campbell, Lance wrote: > Michael, > So based on your feedback would it be better to do option A or B below? > > 1) I have a timestamp field, "some_timestamp", in table "some_table". > 2) I want to compare field "some_timestamp" to the current date - 1 day. > I need to ignore hours, minutes and seconds. > You might want to use date_trunc then: select * from sometable where date_trunc('day',tiemstampfield) > date_trunc('day',now() - interval '1 day'); or something like that.