Hello friends,
I am working on a simple program to check the date in my code.I need to add 25days excluding weekends so as i can get the Date of the 25th day from my code.Is their anyone who can help me solve that?
Below is what am trying to check
public int NumberOfDays(DateTime startDate, int endDate)
{
int numberOfDays = 0;
DateTime end = startDate.AddDays(endDate);
while (startDate != end)
{
if (startDate.DayOfWeek != DayOfWeek.Saturday && startDate.DayOfWeek != DayOfWeek.Sunday)
{
numberOfDays++;
}
startDate = startDate.AddDays(1);
}
return numberOfDays;
}
Mark as answer if satisfied