Link to home
Start Free TrialLog in
Avatar of Scott Bennett
Scott BennettFlag for United States of America

asked on

datediff question

I want to calculate and display how many years and months it has been since a certain date.

I want code that will say "It has been 2 years 3 months since October 01, 1999." where the "2 years 3 months" part is dynamically generated based on the curent date.

This is what I have so far but it is not working quite right:

it has been <%= DateDiff("yyyy", DateValue("October 01, 1999"), Date)%>  years <%= DateDiff("m", DateValue("October 01, 1999"), Date) - (DateDiff("yyyy", DateValue("October 01, 1999"), Date) * 12)%> Months since October 01, 1999
ASKER CERTIFIED SOLUTION
Avatar of thunderchicken
thunderchicken

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 Scott Bennett

ASKER

That must have been what was throwing me off. I thought the DateDiff would only count whole years not just compare the value of the year without taking the months into consideration. Thanks a lot.