Multiple Iif in Query Builder

zooropa66

Registered User.
Local time
Today, 08:58
Joined
Nov 23, 2010
Messages
61
I have the following field in Query Builder

Code:
Status: IIf(DateValue(Now())>DateValue([Expiry Date]),"Expired","Current")

and it works fine

What I would like, however, is to include the following condition into the above

Code:
Status: IIf(DateValue([Expiry Date] - DateValue(Now()) < 2),"Nearly Expired","Current")

so in effect the status would be either current, nearly expired or expired

Can anyone help? Thanks
 
Thanks for your reply. I had a look at the link and i'm no further forward. I think you might not have read my question correctly or i haven't explained clearly. I know how to put the two expressions into 2 separate fields in query builder. I want to be able to incorporate them into 1 field!
 
Try:

IIf(DateValue(Now())>DateValue([Expiry Date]),"Expired",IIf(DateValue([Expiry Date] - DateValue(Now()) < 2),"Nearly Expired","Current"))

Simon
 
You can simplify the expression by using Date() instead of Now().
IIf(Date()>DateValue([Expiry Date]),"Expired",IIf(DateValue([Expiry Date]) - Date() < 2),"Nearly Expired","Current"))
 
Thanks for the replies. If I enter the following, the Expired ones show up but the second Iif just returns #error

Code:
Expr1: IIf(DateValue(Now())>DateValue([Expiry Date]),"Expired",IIf(DateValue([Expiry Date]-DateValue(Now())<2),"Nearly Expired","Current"))
 
I got it. Just a small tweak required. Here it is.

Code:
Expr1: IIf(DateValue(Now())>DateValue([Expiry Date]),"Expired",IIf(([Expiry Date]-Date()<2),"Nearly Expired","Current"))

Thanks for your help everyone
 
Try this:

Test: IIf(DateValue(Now())>DateValue([Expiry Date]),"Expired",IIf(DateDiff("d",[Expiry Date],Now())>2,"Nearly Expired","Current"))

Simon
 

Users who are viewing this thread

Back
Top Bottom