How do I calculate Day, Month, Year exactly?
Means..
From 2th Jan 1990 to 9th May 2009 is..
xxx Days, xxx Months, xxx Years.
Any idea how to do that?
I tried Timespan and Tick().. Both failed to do so..
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You cannot do it through direct calculation (i.e. there’s no “TotalMonths” or “TotalYears” property of
TimeSpan, simply because those numbers do not make sense with arbitrary intervals of time).Instead, you can just count the number in a loop, like so:
I haven’t tested this, so there might be off-by-one errors or whatever, but that’s the basic idea.