使用Powershell如何获得工作日数? [英] Using Powershell how do you get the weekday number?
本文介绍了使用Powershell如何获得工作日数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 Powershell 日期对象如何获取星期几,0 到 6,其中 0 表示星期日,6 表示星期六.我知道我可以使用下面的代码获取日期名称,但是由于没有 DayNumberOfWeek 或等效属性,我如何获取数字?
Using a Powershell date object how do you get the day number of the week, 0 to 6 where 0 would be Sunday and 6 would be Saturday. I know that I can get the day name with the code below but how do I get the number as there is no DayNumberOfWeek or equivalent property?
(Get-Date).DayOfWeek
我想我可以在 switch 语句中使用上面代码中的日期名称将其转换为数字,但这似乎不是很有说服力.
I suppose I could use the day name from the code above in a switch statement to convert it to a number but that doesn't seem to be very eloquent.
推荐答案
像这样:
( get-date ).DayOfWeek.value__
我建议将来以这种方式调查对象的哪些属性:
I suggest for the future to investigate what properties an object in this way:
( get-date ).DayOfWeek | gm -f # gm is an alias for get-member
这篇关于使用Powershell如何获得工作日数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文