I provide an answer for this in another thread, my example was even based on a table of holidays just like you are looking for.  As once mentioned, you can create in temporary table to join against the table with the dates.  I did mine inline.  This is an oracle base example, but I'm sure a similar solution would exist for most major DBMS.


SELECT
    DATETEST.DATE_COL,
    All_DAYS.DAYS,
    DATETEST.R_MED_EDATE,
    DATETEST.R_MED_DESC
  
FROM
    DATETEST,
    (    SELECT
             TO_DATE('01/01/2004', 'MM/DD/YYYY') - 1 + rownum AS DAYS
         FROM
             all_objects
          WHERE
             TO_DATE('01/01/2004', 'MM/DD/YYYY') - 1 + rownum <= TO_DATE('01/31/2004', 'MM/DD/YYYY')
    ) All_DAYS

WHERE
    ALL_DAYS.DAYS = DATETEST.DATE_COL(+)

--------------
Ian Skinner
Web Programmer
BloodSource
www.BloodSource.org
Sacramento, CA

-----Original Message-----
From: C. Hatton Humphrey [mailto:[EMAIL PROTECTED]
Sent: Thursday, January 29, 2004 8:33 AM
To: CF-Talk
Subject: Calendar query?

Does anyone know of a way to create a query with a range of dates and any
matching records that might match in a database in one query?  For example,
if I'm looking at a table that has the following:

ID | Date       | Event
---+------------+-------------------
1 | 01/01/2004 | New Years Day
2 | 02/14/2004 | Valentine's Day
3 | 01/26/2004 | Mom's Birthday
4 | 02/04/2004 | Doctor's Appointment

Say I wanted to show all of the days between 01/15/2004 and 02/15/2004 along
with any matching events in the database.  Is there a way to do this with
one query?  So far the only two ways that I can see doing it otherwise is to
loop through the date range and perform individual queries... Which IMO is a
little inefficient.

Any ideas?

Thanks!
Hatton

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.572 / Virus Database: 362 - Release Date: 1/27/2004
  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to