| From: | george young <gry(at)ll(dot)mit(dot)edu> |
|---|---|
| To: | "Jeff Barrett" <jbarrett(at)familynetwork(dot)com> |
| Cc: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: seleting all dates between two dates |
| Date: | 2001-06-06 16:31:17 |
| Message-ID: | 20010606123117.097eb4cd.gry@ll.mit.edu |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
On Fri, 1 Jun 2001 15:09:33 -0400
"Jeff Barrett" <jbarrett(at)familynetwork(dot)com> 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]
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Linh Luong | 2001-06-06 16:34:32 | Cascade constraint gone!!! |
| Previous Message | george young | 2001-06-06 16:24:06 | Memory exhausted in AllocSetAlloc |