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
Another way is:
"$(Get-date -f yyyy)$("{0:00}" -f [Math]::ceiling((Get-date -f MM)/3) )"
one way is:
$yearYYYYQQ = "$(get-date -uformat %Y)$("{0:00}" -f [int]((get-date).month/4) )"
"$([datetime]::Now.Year)$(([math]::Ceiling(([datetime]::Now.Month)/3)).ToString().PadLeft(2,"0"))"
Another way:
$today = Get-Date
$YearYYYYQQ = "{0}{1:d2}" -f ($today.Year, [int][math]::Ceiling($today.Month/3))