Write to us
MS SQL Server
Free Tech Magazines
Asp.Net Web Hosting
Link to Us
Questions & Answers
Tips & Tricks
How To Find Number of Days between two Dates in C# Asp.Net?
1/30/2009 8:03:38 AM
To calculate the number of days between two dates in Asp.Net using C#, use the below piece of code.
TimeSpan timespan = Convert.ToDateTime("2009-12-31").Subtract(Convert.ToDateTime("2009-01-01"));
Here we use Subtract method to find the difference between two dates. Usually the Subtract method return a value that is one less than the correct value. So to the Timespan object's Days property we can add 1 to get the exact number of days.
Post New Tips/Tricks
View all Tips/Tricks
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
A free magazine offering practical advice and helpful tools from industry experts to help any website achieve Internet success.
100% Free Subscription until Stock lost.
View complete list.
. www.AspdotnetCodes.com. All rights reserved.