Received: from ll.mit.edu (LLMAIL.LL.MIT.EDU [129.55.12.40]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f56GVME13500 for ; Wed, 6 Jun 2001 12:31:22 -0400 (EDT) (envelope-from gry@ll.mit.edu) Received: (from smtp@localhost) by ll.mit.edu (8.11.3/8.8.8) id f56GVK024559; Wed, 6 Jun 2001 12:31:20 -0400 (EDT) Received: from UNKNOWN( ), claiming to be "soi.llan" via SMTP by llmail, id smtpdAAACoaasV; Wed Jun 6 12:31:17 2001 Received: from sty (sty [ ]) by soi.llan (8.8.0/8.8.0) with SMTP id MAA12564; Wed, 6 Jun 2001 12:31:17 -0400 (EDT) Date: Wed, 6 Jun 2001 12:31:17 -0400 From: george young To: "Jeff Barrett" Cc: pgsql-sql@postgresql.org Subject: Re: seleting all dates between two dates Message-Id: <20010606123117.097eb4cd.gry@ll.mit.edu> In-Reply-To: <9f8pg1$kem$1@news.tht.net> References: <9f8pg1$kem$1@news.tht.net> X-Mailer: Sylpheed version 0.4.62 (GTK+ 1.2.8; i586-pc-linux-gnu) Organization: MIT Lincoln Laboratory Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Archive-Number: 200106/66 X-Sequence-Number: 3282 On Fri, 1 Jun 2001 15:09:33 -0400 "Jeff Barrett" wrote: > I am interested in a query where I can select all dates between two dates. I > figure I can build a table of all valid dates with a resonable range and > then select from that table, but I would like to use the power of sql to get > the work done without building a date table. Any ideas? > > For example: > I want all dates between 05-29-2001 and 06-02-2001 > The result set would be: > 05-30-2001 > 05-31-2001 > 06-01-2001 You got it almost right already! Use the "between" operator; *sometimes* SQL *is* intuitive: E.g. in my database: select run_name from runs where comp_date between '2001-may-10' and '2001-jun-5'; run_name | comp_date ------------------+------------------------ spcsil-103-RP | 2001-06-04 21:09:35-04 airtest_0120 | 2001-05-21 20:10:50-04 spcsil-101-RP | 2001-05-23 17:44:11-04 ... -- Your mouse has moved. Windows NT must be restarted for the change to take effect. Reboot now? [OK]