Re: how to match time ranges for multiple records in a query?
- From: "Chris Hohmann" <nospam@xxxxxxxxxxxx>
- Date: Wed, 9 Nov 2005 10:34:08 -0800
"mike" <mike_newsgroups@xxxxxxxxx> wrote in message
news:1131483428.302442.246690@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Sorry for the late reply, for some reason google didn't show this
> thread on my recent threads with some activity.
>
> I changed the Schedules table to make this easier by removing the day
> column, now it looks like this (real data):
>
>
> ID userID timeStart timeEnd
> 87 8 11/7/2005 8:00:00 AM 11/7/2005 11:30:00 PM
[snip]
>
> What I want to do is find ALL of the overlapping times, the time range
> of the overlaps, and which userids are part of each overlap.
[snip]
SELECT S1.userID AS userID,
IIF(S1.timeStart > S2.timeStart, S1.timeStart, S2.timeStart) AS
timeStart,
IIF(S1.timeEnd < S2.timeEnd, S1.timeEnd, S2.timeEnd) AS timeEnd
FROM Schedule AS S1
INNER JOIN Schedule AS S2
ON S1.userID <> S2.userID
AND S1.timeStart < S2.timeEnd
AND S1.timeEnd > S2.timeStart
.
- Follow-Ups:
- References:
- Re: how to match time ranges for multiple records in a query?
- From: mike
- Re: how to match time ranges for multiple records in a query?
- From: Bob Barrows [MVP]
- Re: how to match time ranges for multiple records in a query?
- From: Bob Barrows [MVP]
- Re: how to match time ranges for multiple records in a query?
- From: Chris Hohmann
- Re: how to match time ranges for multiple records in a query?
- From: Chris Hohmann
- Re: how to match time ranges for multiple records in a query?
- From: Bob Barrows [MVP]
- Re: how to match time ranges for multiple records in a query?
- From: mike
- Re: how to match time ranges for multiple records in a query?
- Prev by Date: Re: A Challenging Problem I'm Trying to Resolve ....
- Next by Date: Re: stuck on random record code example from ASPFAQ.com
- Previous by thread: Re: how to match time ranges for multiple records in a query?
- Next by thread: Re: how to match time ranges for multiple records in a query?
- Index(es):