Created
October 16, 2012 18:58
-
-
Save rodolfofadino/3901237 to your computer and use it in GitHub Desktop.
Business Day C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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