Automatic Data Extraction for Fri-Sat-Sun on Mondays

G

Guest

I am trying to pull data on a Monday where the entries from the previous day
are extracted from the database, and I setup the query to read "Date()-1" in
the criteria line of my query, and this works for every other day of the
week, but I realized on Monday this simple query won't work, as I need to
pull the information entered on Friday, Saturday and Sunday for Monday's
query.

I asked this question previously and someone said I should use this:
"IIf(Weekday("MyDate",2)<5,"MyDate","MyDate"+(8-Weekday("MyDate",2)))"

But either I'm not adding this correctly to my query, or I'm missing
something, because it gives me a "data type mismatch" error message when I
try to run the query. I'd like to leave my "Date()-1" in the criteria line
because this works for pulling data Tue-Fri from the previous days' entires,
but if that can be worked into the entire criteria I guess that would work as
well. If someone could please help me figure out what I need to type for
this criteria (not SQL) in the query I would be very thankful!

Have a great Monday everyone!
 
J

John Spencer (MVP)

I would use CRITERIA something like the following against your date field.

Between IIf(Weekday(Date(),3)<5,Date()-1,Date()-3) and Date()-1

That should give you entries for Date()-1 on Tuesday through Friday

And then for Friday through Sunday on Mondays
 

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