View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
John James
 
Posts: n/a
Default i have two days and i want the difference in days, months, year


Ron,

And all three methods apparently correctly measure what they are
attempting to measure, based on the examples you cited.

The CalendarMonths UDF is a very specific calculation for an unusual
need - it apparently calculates the number of full calendar months
between two dates and adds the left-over days on both sides. Hence the
unusual 60 days difference on your last example. There could be
variations on this formula depending upon how you wanted to treat year
differences.

The other two methods are what I would expect most people would
consider core needs, and be looking for in calculating date
differences.

My latest formula takes the higher date, then deducts years, then
months, then days.

Your DateInv UDF takes the lower date, then adds years, then months,
then days.

Both are valid, are a common need, and should in my view be catered for
with in-built, supported date difference formula parameters. The
in-built formula should additionally allow for negative date
differences, rather than falling over.

Ron, maybe if you're so motivated, you could adjust your DateInv
formula to allow a parameter for this different direction of
calculation, and even to allow for negative date differences. That
could be a relatively popular addin (or a part of a more wide-ranging
date difference addin), assuming it's not reinventing the wheel. (My
VBA skills aren't yet up to the task) Even better if Microsoft acted.
If you're not interested or don't have time, maybe it could be posted as
a challenge on the Excel programming group, and hopefully one of the MVP
sites would pick it up.


--
John James
------------------------------------------------------------------------
John James's Profile: http://www.excelforum.com/member.php...o&userid=32690
View this thread: http://www.excelforum.com/showthread...hreadid=534015