As recommende, I used the expression
=IIf(IsNull([CompletionDate]),"",IIF((date()-
[BeginDate])>60,Sum(date()-[BeginDate])-60,""))
Unfortunately this does not work for what I am after. This expression is
stating that if the completion date is null, then leave my return value
null,
otherwise give me the difference between todays date and the [begin date]
less 60 days. For the "overdue" control, this calculation is to occur if
the
[completion date] is null AND todays date is greater than 60 days past the
[begin date].
IIf(([begin date] + date ()) > 60 AND IIf(IsNull([CompletionDate]))),
Sum(date()-[BeginDate])-60, "" (something is wrong with this expression
so
it doesn't work)
If I could get the above expression to work, then I would be able to
calculate those items that are overdue past the 60 day deadline and
indicate
the number of days that it is overdue.
For late items I need to show those items that do have a completion date
entered but where the [begin date]-[completion date] >60 so as to indicate
how many days over the 60 they were late.
--
Thanks!
storrboy said:
I am trying to use this logic in a similar situation that I have where
I need
to calculate two separate dates, one for "late" and one for "overdue".
In my
scenario I have a control in a form that looks at several fields
[beginDate],
[completionDate], and [dueDate]. All projects have a 60 day timeframe
for
required completion, so the [dueDate] is a control set to
[beginDate]+60.
That's the easy part. Now I need to indicate how many days a project
is
overdue e.g. the[completionDate]Is Null and it has been greater than 60
days,
and another control needs to indicate how many days late the project
was
completed, e.g the [completionDate]-[BeginDate]>60.
I have tried the following respectively but they don't seem to work
properly
Overdue: IIf(([CompletionDate] Is Null) AND
(date()-[BeginDate]))>60,Sum(date()-[BeginDate])-60,"")
Late:
=IIf(([CompletionDate]-[BeginDate])>60,Sum([CompletionDate]-[BeginDate])-60,"")
Any ideas?
--
Thanks!
Overdue:
Is Null is only used in SQL. Use the IsNull() function in controls and
procedures ie. IsNull([CompletionDate]). Try using
=IIf((IsNull([CompletionDate]),"",IIF((date()-
[BeginDate])>60,Sum(date()-[BeginDate])-60,""))
Second you may find more reliable results by using the various date
functions (DateDiff, DateAdd etc.) instead of straight math.