Skip to content

Instantly share code, notes, and snippets.

@rodolfofadino
Created October 16, 2012 18:58
Show Gist options
  • Save rodolfofadino/3901237 to your computer and use it in GitHub Desktop.
Save rodolfofadino/3901237 to your computer and use it in GitHub Desktop.
Business Day C#
public static class DateExtensions
{
public static int BusinessDay(this DateTime data)
{
var inicioMes = new DateTime(data.Year, data.Month, 1);
int total = 0;
while (inicioMes.Date <= data.Date)
{
if (inicioMes.DayOfWeek != DayOfWeek.Friday && inicioMes.DayOfWeek != DayOfWeek.Sunday)
total++;
inicioMes = inicioMes.AddDays(1);
}
return total;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment