Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compound IIf function 2

Status
Not open for further replies.

dbero

Technical User
Mar 31, 2005
109
US
I am trying to execute the compound IIf function below. Each of these work fine individually, but when I put in the AND to join the 2, it doesn't work. The logic is if the day of week is Wed,Thur,Fri or Sat, and the 2 dates are in the same week count, then value is "NotbackDated. Should this work?


IIf(DayofWeek="Wednesday" Or DayofWeek="Saturday" Or DayofWeek="Friday" Or DayofWeek="Thursday" And Format([SISSEffectiveDt],"ww")=Format([SUBM Processed Dt],"ww"),"NotBackDated","BackDated") AS Pricing
 
Take care of brackets when mixing OR and AND operators:
IIf([highlight]([/highlight]DayofWeek="Wednesday" Or DayofWeek="Saturday" Or DayofWeek="Friday" Or DayofWeek="Thursday"[highlight])[/highlight] And Format([SISSEffectiveDt],"ww")=Format([SUBM Processed Dt],"ww"),"NotBackDated","BackDated") AS Pricing

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Do you mean it doesn't give the expected results? The OR/AND does not match up correctly, I assume.

IIf((DayofWeek="Wednesday" Or DayofWeek="Saturday" Or DayofWeek="Friday" Or DayofWeek="Thursday") And Format([SISSEffectiveDt],"ww")=Format([SUBM Processed Dt],"ww"),"NotBackDated","BackDated") AS Pricing
 
Great Catch!! Missing the ( )was the problem. Thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top