IF Condition for WEEKDAY

G

Guest

I have a query that runs daily. I have the "complete date" field set to "<
Date()-1" So it shows itemse with a recieved date of "yesterday" whenever the
query is run. Well, on Mondays I need to to show Friday (which would be
"Date()-3" ). How can I write an "IF" clause so If the weekday is Monday,
True: use Date()-3 False: Date()-1

Please help,
Angel
 
M

Marshall Barton

AngelMdc3 said:
I have a query that runs daily. I have the "complete date" field set to "<
Date()-1" So it shows itemse with a recieved date of "yesterday" whenever the
query is run. Well, on Mondays I need to to show Friday (which would be
"Date()-3" ). How can I write an "IF" clause so If the weekday is Monday,
True: use Date()-3 False: Date()-1


Try using: Date() - IIf(DatePart("w", Date()) = 2, 3, 1)
 
C

Chris2

AngelMdc3 said:
I have a query that runs daily. I have the "complete date" field set to "<
Date()-1" So it shows itemse with a recieved date of "yesterday" whenever the
query is run. Well, on Mondays I need to to show Friday (which would be
"Date()-3" ). How can I write an "IF" clause so If the weekday is Monday,
True: use Date()-3 False: Date()-1

Please help,
Angel

Wouldn't that be:

"< IIF(DatePart("w", Date()) = 6, Date() - 3, Date() -1)"
 
G

Guest

Please help me as well -

I am entering data that is pulled the "next day" and realize that I need to
pull on Monday all the data entered Friday, Saturday and Sunday - can someone
help me write a clause so that this will happen - the item below pulls
Friday's data wonderfully, but how do I accomplish all 3?

HELP!
 
G

George Nicholson

NextDay = IIF(Weekday(MyDate,2)<5, MyDate, MyDate + (8-Weekday(MyDate,2)))

Weekday(MyDate,2) The 2 tells Weekday to use Monday as "Start of week", so
it will return 5, 6, 7 for Fri, Sat, Sun
So: If Mon-Thur, NextDay = the same date. If Fri-Sun, NextDay = the
following Monday (MyDate + 3, 2 or 1).

HTH,
 
G

Guest

Thanks, I'll give it a try - hopefully it'll work - I'll let you know on
Monday when I pull the data - thanks George!
 

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