Difference between two dates in Years and Months.

F

Floyd Forbes

I'd like the difference between two dates to be displayed in years and
months.
How do I format the DateDiff function so that I can achieve this?

Appreciate any help!

Floyd
 
K

Ken Snell

Use DateDiff to return the number of months, then change that to years and
months (note that partial months may be incorrectly calculated as full
months using DateDiff):

NumberOfYears = DateDiff("m", StartDate, EndDate) \ 12
NumberOfMonths = DateDiff("m", StartDate, EndDate) - NumberOfYears * 12
 

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