date diff using criteria

C

CAMI Lady

I may be going about this all wrong, if so advice always appreciated.
In the form and in the report I need to display the number of days elapsed -
if the DateResolved is blank then the number of days between SubmittedDate
and today and if the DateResolved is not blank then the number of days
between SubmittedDate and DateResolved
I have been putting it in an unbound text box on the form and report. This
is the formula I have been playing with, it only works halfway, it shows the
number of days between Submission and Resolved, but not Submission and todays
date
=IIf([DateResolved]="",DateDiff("d",[SubmittedDate],Date()),DateDiff("d",[SubmittedDate],[DateResolved]))
thanks in advance
 
S

S.Clark

Try
=IIf(Len([DateResolved])=0,DateDiff("d",[SubmittedDate],Date()),DateDiff("d",[SubmittedDate],[DateResolved]))
 
J

John Spencer

=IIf([DateResolved] is null
,DateDiff("d",[SubmittedDate],Date())
,DateDiff("d",[SubmittedDate],[DateResolved]))

OR you could use the simpler expression

=DateDiff("d",[SubmittedDate],Nz([DateResolved],Date()))

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
K

KARL DEWEY

Try this --
=IIf([DateResolved] Is Null, DateDiff("d",[SubmittedDate], Date()),
DateDiff("d",[SubmittedDate], [DateResolved]))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top