Skip to content
Loading
  • Satya Karki
    +1
    Hi,
     
    Check this function;
     
    1. public int CalculateAgeCorrect(DateTime birthDate)  
    2. {  
    3.     Datetime now = Datetime.Now;  
    4.     int age = now.Year - birthDate.Year;  
    5.   
    6.     if (now.Month < birthDate.Month || (now.Month == birthDate.Month && now.Day < birthDate.Day))  
    7.         age--;  
    8.   
    9.     return age;  
    10. }  
     
    +1
  • Rijwan Ansari
    +1
    Hi,
     
    for age in year
     
    1. DateDiff("yyyy", Now, TheDate)  
    https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/datediff-function 
    +1