>I have two dates: ldBirthdate and ldPlanYear
>
>ldBithdate = {07/01/1926}
>ldPlanYear = {12/31/1997}
>
>I need to know two things:
>
>1) Did this person turn 70.5 (70 and 1/2) during ldPlanYear?
>2) If not, which year did this person turn 70.5
>
>For some reason all my calculations are not working. Perhaps I'm overtired? This should be pretty easy, right? Any help would be greatly appreciated.
When the person turns 70.5 depends on how you calculate years. Is 70.5 in the middle of the day on 365/2th day of the 70th year? Or is it 70 years and 6 months from the birthday?
There are several methods in the financial world for calulating number of years between 2 dates. The most common is 30/360. Here's a function to return the number of years between two dates using the 30/360 method. You can check whether the result of this function is greater than or less than 70.5:
FUNCTION Years
LPARA ldStart, ldEnd
IF TYPE('ldStart') <> "D" OR TYPE('ldEnd') <> "D"
RETURN 0
ENDIF
LOCAL lnStartDay, lnEndDay, lnStartMonth, lnEndMonth, lnStartYear, lnEndYear, lnDays, lnYears
lnStartDay = DAY(ldStart)
lnEndDay = DAY(ldEnd)
lnStartMonth = MONTH(ldStart)
lnEndMonth = MONTH(ldEnd)
lnStartYear = YEAR(ldStart)
lnEndYear = YEAR(ldEnd)
lnStartDay = IIF(lnStartDay = 31, 30, lnStartDay)
lnEndDay = IIF(lnEndDay = 31, 30, lnEndDay)
lnDays = (lnEndDay - lnStartDay) + (30 * (lnEndMonth - lnStartMonth)) + (360 * (lnEndYear - lnStartYear))
lnYears = lnDays / 360
RETURN lnYears
ENDFUNC
Erik Moore
Clientelligence