“Birth Date” - OnValidate IF "Birth Date" <>0D THEN BEGIN Age:= TODAY -"Birth Date" ; //Returns number of days old Age2:=(Age/365.2364); //Returns number of years old as Decimal - Takes into Account Leap Years i:= STRPOS(FORMAT(Age2),'.'); IF i>0 THEN Agestr:= COPYSTR(FORMAT(Age2),1,i-1) //Return no of years old as string – removes decimal value ELSE Agestr:= FORMAT(Age2); //Return no of years old as string LastBDayTxt := '+' + AgeStr + 'Y'; //Creates a date formula ie +30Y LastBDayDate := CALCDATE(LastBDayTxt,"Birth Date"); //Returns last Birthday Age1:= (TODAY - LastBDay); //Returns number of Days since last birthday END;
Comments
I've a problem with this formula:
TODAY: 4.09.2018 (september)
Birth: 3.09.2008 => age: 10 ok!
Birth: 4.09.2008 => age: 9 (9.999...) not ok, it's birthday!
Birth 5.09.2008 => age: 9 ok!
any idea? something with the 365.2364?
BR
Chris
Check dates:
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Hi @Slawek_Guzek,
Will it work in the below case?
CheckAgeAndBirthday(210991D, 210992D, AgeYears, AgeDays, IsBirthDayDate);