IIF statement with an AND and an OR

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
1,756
Office Version
  1. 365
Platform
  1. Windows
Is this correct?
MONTH1_PDL: IIf(((DateDiff("m",[PDIR Due Date],Now()))>1) And ((DateDiff("m",[PDIR Completed],Now()))=<1) Or ([PDIR Completed] Is Null),1,0)


I need the first condition met and only one of the next two to true

[PDIR Due Date],Now()))>1 Needs to be True

AND
[PDIR Completed],Now()))=<1 OR ([PDIR Completed] Is Null Needs to be True

Should the last two be enclosed in a bracket?
 

Some videos you may like

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
54,821
Office Version
  1. 365
Platform
  1. Windows
Re: Access: IIF statement with an AND and an OR

Not quite. Try this:
Code:
MONTH1_PDL: IIf((DateDiff("m",[PDIR Due Date],Now())>1) And ((DateDiff("m",[PDIR Completed],Now())=<1) Or ([PDIR Completed] Is Null)),1,0)

The trick is to write each condition separately, and comletely, and then just drop into the structure you need, i.e.
IIF((condition1) And ((Condition2) Or (Condition3)),1,0)
 

Watch MrExcel Video

Forum statistics

Threads
1,112,817
Messages
5,542,666
Members
410,567
Latest member
SCraig123
Top