>>>>>See
Re: What is best way to calculate age Thread #
1155605 Message #
1155645>>>>>
>>>>>What should this class return for today and 02/29/1988?
>>>>
>>>>18 years, 6 months, and 22 days.
>>>
>>>How did you calculate that? BTW, it returns 16 days.
>>
>>It returns 18,6,22 as I stated. Are you using the latest version? This class was updated Jan. 2005. The old one may have produced a different result. See the documentation for explanation of how this class does its calculations.
>
>Yes, I downloaded it a few minutes ago. I put 9/14/06 instead of today's date. Anyway, based on the age how do you calculate date, and do your both results match?
I never need to calculate ages, but here what I invent :-)) (I hate endless loops)
ldBegin = DATE(1965, 4, 26)
ldEnd = DATE()
STORE 0 TO lnYear, lnMonhts, lnDays
DO WHILE .t.
DO CASE
CASE GOMONTH(ldBegin,12) <= ldEnd
lnYear = lnYear + 1
ldBegin = GOMONTH(ldBegin, 12)
CASE GOMONTH(ldBegin,1) <= ldEnd
lnMonhts = lnMonhts + 1
ldBegin = GOMONTH(ldBegin, 1)
CASE ldBegin < ldEnd
lnDays = lnDays + 1
ldBegin = ldBegin + 1
OTHERWISE
EXIT
ENDCASE
ENDDO
? lnYear, lnMonhts, lndays
Of couse there is no checking for valid date period and no error handling at all. Also not well tested :-)))
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.