Date Criteria HELP!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello -

I have a query that sets criteria on a DATE field to pull data from the
previous day (if yesterday is not equal to sunday), and if yesterday is equal
to sunday, then it will pull data from friday - sunday.

This is the code I am using:

IIf(Weekday((Date()-1))=1,Between (Date()-3) And Date()-1,Between Date()-1
And Date()-1)

When I run the query with this code, it pulls no records. I've checked
everything that I can think of. By itself, Between (Date()-3) And Date()-1
works fine. I know the Weekday(Date()-1) = 1 for Sunday, since I have used
this code elsewhere.

Something about the IIF statement is messing this up, but I'm not sure what
it is or how to fix it...

Thanks for your help,

Nick
 
Try this.

Between IIf(Weekday(Date())=2,Date()-3) ,Date()-1) and Date()-1

You cannot use an IIF statement to assign an operator )Between ... And ..)
in the manner you attempted. You can use IIF to return a value or call a
function that returns a value such as Date().
 
Little correction syntax wise, but this works. Thanks!

Between IIf(Weekday(Date()=2),Date()-3,Date()-1) And Date()-1
 

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

Back
Top