overlaps

  • Thread starter Thread starter jeff
  • Start date Start date
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
 
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
 
-----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
 
Back
Top