Query to get yesterdays data only for a specific time interval
DECLARE @yesterday SMALLDATETIME;
SET @yesterday = DATEADD(DAY,-1,CONVERT(SMALLDATETIME, CONVERT(DATE, GETDATE())));

SELECT ...
WHERE X.stage = 'Approval'
AND X.T_ExitTime &gt;= DATEADD(HOUR, 6, @yesterday)
AND X.T_ExitTime &lt; DATEADD(HOUR, 17, @yesterday)
ORDER BY x.T_ExitTime;


Don't think you want BETWEEN for datetime ranges, unless you really want to include 5:00 PM and not 5:00:00.0000001 PM.


What do BETWEEN and the devil have in common?
Bad habits to kick : mis-handling date / range queries