Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How To Find Number of Days between two Dates in C# Asp.Net?

C# dates days
0
Posted

How To Find Number of Days between two Dates in C# Asp.Net?

0

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”)); Response.Write(timespan.Days+1); 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 Days property we can add 1 to get the exact number of days.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123