DateDiff Partial Year Calculation

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.
 
D

Douglas J. Steele

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.
 

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