-
52
-
416
-
14.05.2009
-
Thailand
I want to calculate the year and month. But I do not know syntax. I can not divide out.
in View
@{
DateTime now = DateTime.Today;
@(now - Model.DateOfBirth)/ (365.25 * 24 * 60 * 60 * 1000)
}
I want results.(Ex.)
Current Age : 20 year 8 month
Thanks for the help.
-
285
-
2710
-
02.07.2012
-
India
to calculate age
int age = now.Year - birthDate.Year;
if (now.Month < birthDate.Month || (now.Month == birthDate.Month && now.Day < birthDate.Day)) age--;
-
52
-
416
-
14.05.2009
-
Thailand
I'm done. I use.
@T("Age") @(DateTime.Today.DayOfYear > Model.DateOfBirth.Value.DayOfYear ? DateTime.Today.Year - Model.DateOfBirth.Value.Year : DateTime.Today.Year - Model.DateOfBirth.Value.Year - 1) @T("Year") @(DateTime.Today.Month - Model.DateOfBirth.Value.Month) @T("Month")
Thanks.