>I have the need to calculate the timespan in years between 2 dates. Getting the number of days between is no problem; figuring out how many years 1426 days is is another question. I am able to get fairly close using days/365.25 but I don't think this is going to cut it. I am aware of the financial terms 30/360 and Actual/Actual, but don't know how to use these methods to calculate duration. Anybody have a clue?
Erik,
I don't know financial rules but this could help :
lparameters tdBirth
ldCalcDate = tdBirth
lnMonths = 0
do while gomonth( ldCalcDate, 1 ) <= date()
ldCalcDate = gomonth( ldCalcDate, 1 )
lnMonths = lnMonths + 1
enddo
lnYears = int( lnMonths / 12 )
lnMonths = lnMonths - ( lnYears * 12 )
lnDays = date() - ldCalcDate
? lnYears, lnMonths, lnDays
I like this one for it takes leap years into account as appropriate.
Cetin