SQL dynamic date but fixed time query

Posted by Marko Lombardi on Stack Overflow See other posts from Stack Overflow or by Marko Lombardi
Published on 2012-06-21T15:03:06Z Indexed on 2012/06/21 15:16 UTC
Read the original article Hit count: 257

Filed under:
|
|

I am trying to write a sql query like the example below, however, I need it to always choose the DateEntered field between the current day's date at 8:00am and the current day's date at 4:00pm. Not sure how to go about this. Can someone please help?

SELECT     OrderNumber
    , OrderRelease
    , HeatNumber
    , HeatSuffix
    , Operation
    , COUNT(Operation) AS [Pieces Out of Tolerance]
FROM         Alerts
WHERE     (Mill = 3) 
    AND (DateEntered BETWEEN GetDate '08:00' AND GetDate '16:00')
GROUP BY OrderNumber, OrderRelease, HeatNumber, HeatSuffix, Operation

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server-2008