Showing overlapping Dates

J

Jeff

I am using th following code to query records where the customer's service
start and end dates fall within a specified date range. The problem with
this code is when I have a non determined ServiceEnd (not entered).
Active customers may not have the "ServideEnd". Any Ideas on how to modify
or rewrite this code so that it also shows the records with a null entry on
the ServiceEnd???

(([RangeStart])<=[ServiceEnd]) AND (([RangeEnd])>=[ServiceStart]))
 
R

RicOl

I would have used the following code idea. When ServiceEnd is Null put in a value long away in tte future say: 12/31 2199.
Dim ServiceEndLongAway
If IsNull(ServiceEnd) Then
ServiceEndLongAway = #12/31 2199#
Else
ServiceEndLongAway = ServiceEnd
Endif
(([RangeStart])<=[ServiceEndLongAway ]) AND (([RangeEnd])>=[ServiceStart]))
If you use a Form field this new field could be invisible...


"Jeff" skrev:
 
D

Douglas J. Steele

(([RangeStart])<=Nz([ServiceEnd], #9999/12/31#)) AND
(([RangeEnd])>=[ServiceStart]))
 
D

Dale Fye

Jeff,

Assuming that [ServiceEnd] will be NULL if it is not entered, rather than
some default value, try:

(([RangeStart])<=(NZ([ServiceEnd], Date()) AND
(([RangeEnd])>=[ServiceStart]))

But the more I look at it, that might not be what you are looking for. You
might want to change the reference to Date() to something like DateAdd("y",
1, [ServiceStart]) if you just want to assume that the service contract
would be for 1 year.

HTH
Dale
 

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