Finding current quarter of year in PowerShell to append in a filename with format “yyyyqq”

后端 未结 4 1783
时光说笑
时光说笑 2020-12-22 02:44

I am trying to find current quarter of year in PowerShell to append in a filename with format yyyyqq.

I have already got current month and week as below

相关标签:
4条回答
  • 2020-12-22 03:22

    Another way is:

    "$(Get-date -f yyyy)$("{0:00}" -f [Math]::ceiling((Get-date -f MM)/3) )"
    
    0 讨论(0)
  • 2020-12-22 03:25

    one way is:

    $yearYYYYQQ = "$(get-date -uformat %Y)$("{0:00}" -f [int]((get-date).month/4) )"
    
    0 讨论(0)
  • 2020-12-22 03:33
    "$([datetime]::Now.Year)$(([math]::Ceiling(([datetime]::Now.Month)/3)).ToString().PadLeft(2,"0"))"
    
    0 讨论(0)
  • 2020-12-22 03:37

    Another way:

    $today = Get-Date
    $YearYYYYQQ = "{0}{1:d2}" -f ($today.Year, [int][math]::Ceiling($today.Month/3))
    
    0 讨论(0)
提交回复
热议问题