I am trying to get the difference between two datetimepickers.
For example: Between X date and Y date, have been past X days, Y months and Z years.
So, if I'd put in the first datetimepicker my birth date and in the second the day of today, I would my exact age, for example: "20 days, 3 months and 26 years".
I tried a few codes, but the results are not correct.
Thanks in advance.
The code is:
string age = "Tu age es de:\n";
age = age + ((Math.Abs(DateTime.Today.Day - dtpage.Value.Day)).ToString()) + " days, ";
age = age + ((Math.Abs(DateTime.Today.Month - dtpage.Value.Month)).ToString()) + " months";
age = age + " y " + ((Math.Abs(DateTime.Today.Year - dtpage.Value.Year)).ToString()) + " years";
MessageBox.Show(age);
EDIT: Solved in C# calculate accurate age