Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

Round date difference to nearest single decimal

I have this formula:

Me.txtCurrentLifeOfAsset = Int(([txtDateInventoryPerformed] - [txtDateofPurchase]) / 365.25)

Which calculates the difference between two dates in whole years.  For example 6/1/2014 - 3/1/2009 is giving me 5.0 years.  But I want it to show the decimal.  In other words 5.2

What do I have to change in the formula to make this possible?
ASKER CERTIFIED SOLUTION
Avatar of McOz
McOz

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Gustav Brock
If you don't need a high precision, this will do:

DecimalYears = CDbl(Format(DateDiff("d", datFrom, datTo) / 365, "0.0"))

/gustav