BKI_DichVuMatDat.CHRMCommon.TinhTuoi C# (CSharp) Method

TinhTuoi() public static method

public static TinhTuoi ( System.DateTime ip_dat_ngay_sinh ) : int
ip_dat_ngay_sinh System.DateTime
return int
        public static int TinhTuoi(DateTime ip_dat_ngay_sinh)
        {
            int ageInYrs = DateTime.Now.Year - ip_dat_ngay_sinh.Year;
            if(DateTime.Now.Month < ip_dat_ngay_sinh.Month || (DateTime.Now.Month == ip_dat_ngay_sinh.Month && DateTime.Now.Day < ip_dat_ngay_sinh.Day))
                ageInYrs--;

            return ageInYrs;
        }