You would need to manually roll back to the previous day to handle before 3am if you are subtracting 3 hours in seconds:
set newH = $H set timeInSeconds = $PIECE(newH, ",", 2) set timeInSeconds = timeInSeconds - (3 * 3600) ; Subtract 3 hours in seconds
if (timeInSeconds < 0) { set newH = $PIECE(newH, ",", 1) - 1_","_(86400 + timeInSeconds) ; Roll back to previous day } else { set $PIECE(newH, ",", 2) = timeInSeconds }
You would need to manually roll back to the previous day to handle before 3am if you are subtracting 3 hours in seconds:
set newH = $H
set timeInSeconds = $PIECE(newH, ",", 2)
set timeInSeconds = timeInSeconds - (3 * 3600) ; Subtract 3 hours in seconds
if (timeInSeconds < 0) {
set newH = $PIECE(newH, ",", 1) - 1_","_(86400 + timeInSeconds) ; Roll back to previous day
} else {
set $PIECE(newH, ",", 2) = timeInSeconds
}
write $ZDATETIME(newH,3)