Difference between dates

B

bacat

I know how to display the variance in days between 2 dates using =DateDiff.
What I need to do now is calculate the variance using 3 dates. Expl: The
lessor of the variance between TODAYDATE & APPROVAL DATE or TODAYDATE &
DISCHARGEDATE
 
B

Bob Barrows [MVP]

bacat said:
I know how to display the variance in days between 2 dates using
=DateDiff. What I need to do now is calculate the variance using 3
dates. Expl: The lessor of the variance between TODAYDATE &
APPROVAL DATE or TODAYDATE & DISCHARGEDATE

You will need to use the IIF() function (yes, there are two "I"s)

SELECT IIf(datediff("d",[APPROVAL DATE],TODAYDATE) <
datediff("d",DISCHARGEDATE,TODAYDATE),
datediff("d",[APPROVAL DATE],TODAYDATE),
datediff("d",DISCHARGEDATE,TODAYDATE)) as LeastVariance,
....
 
J

John Spencer

Try the following and see if it works for you.

DateDiff("d",TodayDate,IIF(ApprovalDate<=DischargeDate,ApprovalDate,DischargeDate))

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
 

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