I have a simple function that I can use that will simply return the hour (in 24 hour format) for the current date/time. I also have some additional code that I can call that function and it will return which quarter of the day it is (qtr 1 is 00:00 - 05:59; qtr 2 is 06:00hrs thru 11:59hrs; qtr 3 is 12:00hrs thru 17:59hrs; qtr 4 is 18:00hrs thru 23:59hrs). I would like to combine that function with the additional code, so that when the function is called, it will return the $qtrday
function GetQtrDay {
return "{0:HH}" -f (Get-Date)
}
$Hr = $(GetQtrDay)
# Test for 1st qtr of day (00:00 hrs thru 05:59hrs)
If (($Hr -ge 0) -and ($Hr -le 5)){
$qtrDay = 1
}
# Test for 2nd qtr of day (06:00hrs thru 11:59hrs)
If (($Hr -ge 6) -and ($Hr -le 11)){
$qtrDay = 2
}
# Test for 3rd qtr of day (12:00hrs thru 17:59hrs)
If (($Hr -ge 12) -and ($Hr -le 17)){
$qtrDay = 3
}
#Test for 4th qtr of Day (18:00hrs thru 23:59hrs )
If (($Hr -ge 18) -and ($Hr -le 24)){
$qtrDay =4
}
$qtrDay