DateDiff Partial Year Calculation

  • Thread starter Thread starter ITAnnaJones
  • Start date Start date
I

ITAnnaJones

I am using the DateDiff function to calculate the difference in years
between two dates to show two decimal places for a partial year result.
Any help in formatting this output correctly is appreciated.
 
DateDiff only returns a Long Integer.

I suppose you could have DateDiff return the number of months, and divide by
12, or the number of days, and divide by 365.25, but both of those
approaches will have inaccuracies. That's because DateDiff returns how many
"boundaries" are crossed between the two dates. What I mean by this is that
if you use DateDiff("yyyy", #12/31/2006#, #01/01/2007#) to calculate the
number of years between 31 Dec, 2006 and 01 Jan, 2007, the function will
return 1 year, even though it's only 1 day. That's because it's crossed 1
year boundary between the two dates.
 
Back
Top