-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Your written explanation doesn't match your example IIf() expression.
The SQL translation of your written explanation is:
WHERE [Date Received] - Date() > 60
AND [Date Closed] IS NOT NULL
But that is not what your expression says.
Your inner IIF() function translates to:
If the Date Closed is NULL use the current (Date()), otherwise, use the
Date Received. Huh?!
Then the DateDiff() function figures out the number of days between the
Date Received and whichever date was chosen by the inner IIf() function.
If Date Closed is NOT NULL, then Date Received will be used. Then the
complete expression will evaluate to zero:
Date Received - Date Received = 0
I believe your complete expression should be:
IIf(DateDiff("d",[Date Received],IIf(IsNull([Date Closed]),date(),
[Date Closed])))>60,"Jeopardy","")
Which in SQL WHERE clause would be:
WHERE [Date Received] - Nz([Date Closed], Date()) > 60
The Nz() function "says" "If the first expression is NULL, use the
second expression." IOW, if Date Closed is null, use Date().
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQie6HoechKqOuFEgEQJ1XgCgscpooeHVOw/IjLpQ/YWcuk5w6xEAoMqH
oTSD9o2LXu+6Y4P77jqQJLiT
=brVi
-----END PGP SIGNATURE-----
Hi, Johnny.
In query design view, enter the criteria for each on the same row, thus
creating a logical AND conjunction between the criteria.
Received Date: (Date()-[ReceivedDate])>60
Closed Date: Is Null
Or, in SQL,
SELECT fieldlist
FROM YourTable
WHERE (((Date()-[ReceivedDate])>60) AND ((YourTable.ClosedDate) Is Null));
Hope that helps.
Sprinks
:
I need a query to identify records that have been opened longer than 60 days
from the received date, but excluding records that are closed (closed date is
Null). I have a statement in a form that displays a message if the key date
is past 60, but cannot work out how to get it into a query:
IIf(DateDiff("d",[Date Received],IIf(IsNull([Date Closed]),date(),[Date
Received])))>60,"Jeopardy",""