Created
July 28, 2017 11:38
-
-
Save rdbartram/957cd3a5340709ea8f4cc0b722748f8e to your computer and use it in GitHub Desktop.
Get workday x days ago
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
function Get-PreviousWorkday ($Days = 0) { | |
begin { | |
$date = get-date | |
} | |
process { | |
$i = 0 | |
do { | |
$date = $date.adddays(-1) | |
if ($date.DayOfWeek -match '^[^s]') { | |
$i++ | |
} | |
} while ($i -lt $days) | |
} | |
end { | |
return $date.Date | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment