I am calculating an "orders per hour" rate. However, I only want to use data from hours that are complete, i.e. if it is 8:15, I do not want to use data from any orders between 8:00 and now. I only want to use data from orders between 5 am and 8:00 (or 7:59).
This is the query that I have been using to give me how many minutes have passed since the first order was packed today (after 5:00 am). I use this to calculate how many orders are packed per minute. However, I want to further narrow it down to only orders that were packed between 5 and the current hour, demonstrated by the commented out line. This is the calculation that I need help figure out how to right.
DATETIMEPACKED >= CONVERT(VARCHAR, GETDATE(), 110) + ' 05:00:00'
-- and datetimepacked "hour" is less than the "hour" of current time.
Thanks for the help!