LoginSignup
1
0

More than 5 years have passed since last update.

PowerShellで 指定した年月に含まれる日数を取得してみる

Last updated at Posted at 2016-11-26

初学者なので、基礎的なところをいろいろと試しています。

.NetFramework の、
System.DateTime クラスにある DaysInMonth メソッドを呼んでみます。


Write-Host "2016年"
 for ($month = 1; $month -le 12; $month++)
    {
    $nichi = [DateTime]::DaysInMonth(2016, $month)
    Write-Host $month "月は" $nichi "日あります"
    }

実行結果は、

2016年
1 月は 31 日あります
2 月は 29 日あります
3 月は 31 日あります
4 月は 30 日あります
5 月は 31 日あります
6 月は 30 日あります
7 月は 31 日あります
8 月は 31 日あります
9 月は 30 日あります
10 月は 31 日あります
11 月は 30 日あります
12 月は 31 日あります
1
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0