Reputation: 520
I have thousands of customers orders. I just need a count of all orders placed after 5:00 PM going back to the very first entry. How would I query this?
SELECT COUNT(OrderID) AS TotalOrders
FROM Nop_Order
WHERE (CreatedOn > '???')
Upvotes: 3
Views: 326
Reputation: 1517
SELECT COUNT(OrderID) AS TotalOrders
from Nop_Order where datepart(hh, CreatedOn) > 17
Upvotes: 1
Reputation: 37398
You'll want to use the DATEPART
function to isolate just the time component of the date, and compare it to 17
, which would be 5:00 PM in military time...
SELECT COUNT(OrderID) AS TotalOrders
FROM Nop_Order
WHERE (DATEPART(HOUR, CreatedOn) >= 17)
Upvotes: 5