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 > '???')
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)
SELECT COUNT(OrderID) AS TotalOrders
from Nop_Order where datepart(hh, CreatedOn) > 17
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With