Query previous day with GETDATE()-1 and a time period from/to
<p>I want to get total counts from <code>SuperScottTable1</code> from the previous day and narrow to a time frame (From-To). The below works fine until I add </p>

<pre><code>AND (time &gt; '08:00:00.000' AND time &lt; '22:00:00.000')
</code></pre>

<p>It does not error, just returns null.</p>

<p>Is this possible to do?</p>

<pre><code>SELECT 
    SUM(COALESCE(confirmedCount, 0))
FROM 
    SuperScottTable1
WHERE
    superLaneID = '90099' 
    AND time &gt;= GETDATE()-1 
    AND (time &gt; '08:00:00.000' AND time &lt; '22:00:00.000')
</code></pre>