X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0B679474E61 for ; Mon, 3 Mar 2003 07:10:47 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 47333-01 for ; Mon, 3 Mar 2003 07:10:45 -0500 (EST) Received: from anchor-post-39.mail.demon.net (anchor-post-39.mail.demon.net [194.217.242.80]) by postgresql.org (Postfix) with ESMTP id F0B6A475AAC for ; Mon, 3 Mar 2003 07:10:30 -0500 (EST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-39.mail.demon.net with esmtp (Exim 3.36 #2) id 18pom8-0002Yh-0d; Mon, 03 Mar 2003 12:10:32 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id CD02F16FBB; Mon, 3 Mar 2003 12:10:30 +0000 (GMT) Received: from client.archonet.com (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with ESMTP id 361FA16B84; Mon, 3 Mar 2003 12:10:30 +0000 (GMT) Content-Type: text/plain; charset="iso-8859-1" From: Richard Huxton Organization: Archonet Ltd To: mixo , pgsql-sql Subject: Re: two dates Date: Mon, 3 Mar 2003 12:09:36 +0000 User-Agent: KMail/1.4.3 References: <3E5B1349.80705@beth.uniforum.org.za> In-Reply-To: <3E5B1349.80705@beth.uniforum.org.za> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200303031209.36970.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/64 X-Sequence-Number: 12104 On Tuesday 25 Feb 2003 6:55 am, mixo wrote: > 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=3Ddays between two dates (for 7 days, 16*17*7 =3D which a number > that is > too big for my liking). What is wrong with SELECT id FROM foo WHERE created_date>=3D'2003-01-01' AN= D=20 created_date<=3D'2003-01-07' or similar? I don't see why you need multiple= =20 queries, perhaps I have misunderstood --=20 Richard Huxton