How to count the Number of days between two dates?
How to count the Number of days between two dates?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Jul 23, 2012, 5:03 AM
DateTime dt1 = new DateTime(2012, 7, 1);
DateTime dt2 = DateTime.Today;
double days = (dt2 - dt1).TotalDays;
Console.WriteLine(days); // 22
Add 1 to 'days' if you want it to be inclusive of both end points.
If you're not interested in fractional days, you can use the Days rather than the TotalDays property.