从一个指定的月份中找出全部工作日,这里有一行比较简单的代码:
$month = 7 1..31 | ForEach-Object { Get-Date -Day $_ -Month $month } | Where-Object { $_.DayOfWeek -gt 0 -and $_.DayOfWeek -lt 6 }
只需要简单的设置一个月份到$month(例子中是7月 )。
同时配合更多的命令,这行命令就能用数字返回工作天数:
$month = 7 1..31 | ForEach-Object { Get-Date -Day $_ -Month $month } | Where-Object { $_.DayOfWeek -gt 0 -and $_.DayOfWeek -lt 6 } | Measure-Object | Select-Object -ExpandProperty Count
原文地址: Finding Working Days
本文链接: https://www.pstips.net/finding-working-days.html
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!