try this, needs the UDF FlipcTime()

Code:

$24h = flipctime(@date,"00:00:00"),flipctime(@date,"00:00:00")+86400
$9a = $24h[0]+32400
$5p = $24h[0]+61200
$1150p = $24h[0]+85800


while 1
select
case flipctime(@date,@time) > $9a AND flipctime(@date,@time) < $5p
;this time period if for operations between 9am and 5pm

case flipctime(@date,@time) > $5p and flipctime(@date,@time) < $1150p
;this time period is between 5pm and 11:50pm


case flipctime(@date,@time) > $24h[1]
;this will reset all time variables to equal the new days values.
$24h = flipctime(@date,"00:00:00"),flipctime(@date,"00:00:00")+86400
$9a = $24h[0]+32400
$5p = $24h[0]+61200
$1150p = $24h[0]+85800
endselect

loop