0
compare birthdays and todays date c#
I have a code to compare a birthday to todays date and it can tell you how old you are in years, but I can't get it to tell me the right amount of days. ex you are x years and y days old. The days old is always wrong. I tried using my timespan variable old.totaldays % 365 and that is off by 4 - 5 days every time. any advice would be great.
6 ответов
+ 5
You could forget about leap years. Each 4 years it should add 1 day.
+ 3
Check for how many leap year there are in between current year and the birth year.
Then just add the number of years with the number of days.
+ 1
ok Ill give that a try thank you
+ 1
after doing that it works perfectly thank you
+ 1
Glad i could help. Happy coding🙂.
0
ok that make sense how could I fix that?