Possible Duplicate:
How to get difference between two dates in Year/Month/Week/Day?
How do i calculate exact difference between to date including years, days, moths, weeks. Just like windows calculator does. ?
And represent like this 1 years, 1 months, 1 week, 1 day
I don’t believe there’s anything built into .NET itself which does this in a useful way.
TimeSpan(which you’d get fromdate2 - date1) doesn’t have the concept of months etc – it’s just a duration in ticks, effectively.You can use Noda Time for this, but it’s not quite finished yet. The period calcuation part may well change further… I’m not sure yet. Let me know if you’d like a Noda Time code sample.
Also be aware that arithmetic using dates is fundamentally tricky. Sometimes it’s hard to work out what the right answer should even be…