Imagine I have two DateTime objects, one representing today's date, the other representing the user's supplied date of birth.
I want to do a simple calculation difference between the two dates and output a string in the following format:
17 Years - 2 Months - 18 Days
Them numbers are just examples. How can I achieve this in C#?
EDIT:
Yep I've tried all sorts of combinations, but I was only able to get the Years difference like so:
DateTime userDate = SuppliedDate;
int userAge = DateTime.Now.Year - userDate.Year;
DateTime today = DateTime.Now;
if (userDate > today.AddYears(-userAge))
{
userAge--;
}
Age.Text = userAge.ToString() + " years";
Thank You.