Posted on 2007-11-19
I've created a views that will list all the products- ProductID and quantity, that were ordered (OrderDate) in last twenty four hours between getdate()-1 and getdate().
create view ProductsSold
select orderdetails.ProductID, orderdetails.OrderQty, orders.OrderDate
from OrderDetails inner join Orders
on OrderDetails.salesOrderID = Orders.salesOrderID
where OrderDate > dateadd(d, -1, getdate()) and OrderDate < getdate()
I also tried these:
Where datediff(hh,orderdate,getdate()) <= 24
Where datediff(d,orderdate,getdate()) = 1
but they all produced different results. I thought they would produced the same results.
is it possible to say: where OrderDate between getdate()-1 and getdate()