Excluding records based on dates

M

Murray

I have a table that includes a FromDate field and a ToDate
field. I am trying to fine-tune a query that will, after
I nominate a From Date and a To Date on a form, exclude
all records in my table that conflict with the dates I
have nominated. I have managed to exclude records where
the FromDate falls within my nominated dates, where the
ToDate falls within my nominated dates and where the
FromDate and the Todate both fall within my nominated
dates. But! I cannot manage to exclude records that
overarch my nominated dates alltogether, ie records where
the FromDate is prior to my nominated From Date and the
ToDate falls after my nominated To Date.

Regards

murray
 
N

Nikos Yannacopoulos

Murray,

If I understand correctly, what you want is to select records where both
From and To dates in the table (F and T respectively, in the expression
below) are before the FromDate on the form, or after the To date on the form
(Fm and To respectively, in the expression below)? If that's the case, then
here is your criterion:

(F < Fm And T < Fm) Or (F > To And T > To)

just substitute F and T with the field names in the table, and Fm and To
with the control names on the form.

HTH,
Nikos
 

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