Sum(IIf(DateDiff("d",[Date Entered],[MaxOfDate Entered])>15,1,0))

jamest85

Registered User.
Local time
Yesterday, 16:49
Joined
Jan 20, 2008
Messages
52
Hi:

Previouis developer didn't put comments on below Sum function, so I want to understand this totally before I do any modification, here is the code:

Sum(IIf(DateDiff("d",[Date Entered],[MaxOfDate Entered])>15,1,0)) AS [More than 15 Days]

My questions are:
1. The "Sum" is adding all the "true" values, not adding the days of difference, am i right?
2. why need this format: "15,1,0 "? why not just put: "15" only?

Thank you very much.

James
 
The syntax for the iif function is:
iif ( condition, value_if_true, value_if_false )


so that means if its greater than 15, add 1 if not add 0


so your code checks each date against the max and sees if its greater than 15 days difference. If it is, it counts 1
 

Users who are viewing this thread

Back
Top Bottom