X-Original-To: pgsql-sql@postgresql.org Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id D2AEB475AE5 for ; Sun, 16 Mar 2003 17:37:55 -0500 (EST) Received: by news.hub.org (Postfix, from userid 8) id B1CEB43A611; Sun, 16 Mar 2003 17:37:55 -0500 (EST) From: "D.Sanchez" X-Newsgroups: comp.databases.postgresql.sql Subject: Re: two dates Date: Mon, 17 Mar 2003 09:37:55 +1100 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 39 Message-ID: References: <3E5B1349.80705@beth.uniforum.org.za> X-Complaints-To: usenet@news.hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 To: pgsql-sql@postgresql.org X-Archive-Number: 200303/406 X-Sequence-Number: 12445 If you just want to select all entries created between two given dates, the following query should do it: SELECT column1, column2, .... FROM table WHERE creation_date between to_date('date1','date_format') and to_date('date2','date_format') order by creation_date; This will find all the entries with a creation_date between date1 and date2 and it return the rows sorted by the creation date. You can add additional selection critirias to the WHERE clause if needed. David "mixo" wrote in message news:3E5B1349.80705@beth.uniforum.org.za... > I have a table which has serveral time stamps include when an entry was > 'created'. > Each entry is identified by a unique 'id'. How can I best find entries > created > between two dates without going through each day between the two dates? > > Currently, going through each day to get the results takes about 23 > minutes for 7 days > as I have two other criteria for search: roughly I am doing about > 16*17*n queries, > where n=days between two dates (for 7 days, 16*17*7 = which a number > that is > too big for my liking). > > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org