Hi,
I need to convert how many 'days Old' someone is (e.g. 3 years old = 1,095 days old) to a 'date of birth' answer i.e. dd/MM/yyyy. I have tried many different ways how to do this, but to no avail (yet) - e.g. using a mathematical formula but it gets a bit complicated, especially when considering how to implement that into C# (for a beginner, at least).
What is in the box below is one of the many ways I have tried thus far. I know it's wrong but it's one of many of my attempts. What is the simplest way to go about this (assuming 1 year is 365 days, if the computer doesn't have it's own automated calculation to include leap years)?
Expand|Select|Wrap|Line Numbers
- public static string GetBirthDate(int daysOld)
- {
- var dateToday = Convert.ToInt32(DateTime.Now);
- var calc = (dateToday - 365.25 * daysOld);
- return Convert.ToString(calc);
- }
Kind regards.