Created
July 11, 2019 19:58
-
-
Save andylshort/395302b3e868f6eb808cd1b8611dc000 to your computer and use it in GitHub Desktop.
Get work days between two dates
This file contains 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
private double GetWorkDays(DateTime Start, DateTime End) | |
{ | |
double WorkDays = 1 + ((End - Start).TotalDays * 5 - (Start.DayOfWeek - End.DayOfWeek) * 2) / 7; | |
if (End.DayOfWeek == DayOfWeek.Saturday) WorkDays--; | |
if (Start.DayOfWeek == DayOfWeek.Sunday) WorkDays--; | |
return WorkDays; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment