overlaps

J

jeff

How do I add a Overlap (True/False) field to a query?
My table records have a StartDate and an EndDate. The
query also asks for RangeStart and RangeEnd when I run
the query. I want the Query to have a column showing True
or False for the overlap.

StartDate, EndDate
Overlap
RangeStart, RangeEnd
 
G

Gary Walter

jeff said:
How do I add a Overlap (True/False) field to a query?
My table records have a StartDate and an EndDate. The
query also asks for RangeStart and RangeEnd when I run
the query. I want the Query to have a column showing True
or False for the overlap.

StartDate, EndDate
Overlap
RangeStart, RangeEnd

Hi Jeff,

Whenever I have to deal with an "overlap"
problem, I always go back to this simple
answer Michel once gave on this newsgroup:

** quote **
Ranges do NOT overlap if
( I assume aStart, aEnd, bStart and bEnd are the intervals):

aStart > bEnd OR aEnd < bStart

they overlap, in part or in full, on the negation of that statement, ie
(Apply De Morgan's law) :

aStart <= bEnd AND aEnd >= bStart

** end quote **

I believe the final line gives you the logic for your
Overlap field.

SELECT ... ,
(StartDate<=RangeEnd
AND EndDate>=RangeStart) AS Overlap
FROM ...

Please respond back if I have misunderstood.

Good luck,

Gary Walter
 
J

Jeff

-----Original Message-----



Hi Jeff,

Whenever I have to deal with an "overlap"
problem, I always go back to this simple
answer Michel once gave on this newsgroup:

** quote **
Ranges do NOT overlap if
( I assume aStart, aEnd, bStart and bEnd are the intervals):

aStart > bEnd OR aEnd < bStart

they overlap, in part or in full, on the negation of that statement, ie
(Apply De Morgan's law) :

aStart <= bEnd AND aEnd >= bStart

** end quote **

I believe the final line gives you the logic for your
Overlap field.

SELECT ... ,
(StartDate<=RangeEnd
AND EndDate>=RangeStart) AS Overlap
FROM ...

Please respond back if I have misunderstood.

Good luck,

Gary Walter


.
Gary, Simple solution...can't believe I didn't try
this. Thanks for the help, Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top