title: sql select records between today date plus 16 hours
body: <p>I am trying to get the records between today order date plus 16 hours.</p>
  
  <p><code>OrderDate</code> data type is <code>datetime</code></p>
  
  <p>i have records in database between that period but is not showing using the below query. </p>
  
  <p>For example i have the below records. </p>
  
  <pre><code>2017-03-05 10:20:30.000
  
  2017-03-06 10:20:30.000
  </code></pre>
  
  <p>query should return  the second record. </p>
  
  <p>any suggestions to solve this issue? </p>
  
  <p><strong>SQL Query</strong>   </p>
  
  <pre><code>    SELECT
    dbo.Areas.AreaName,
    dbo.Brands.BrandName,
    dbo.Orders.OrderID,
    dbo.Orders.OrderStatus,
    dbo.Customers.CustomerName,
    dbo.Customers.CustomerID,
    dbo.Customers.Phone,
    dbo.Customers.Mobile,
    dbo.Orders.OrderDate,
    dbo.Outlets.OutletName,
    dbo.Users.FirstName,
    dbo.Users.LastName,
    dbo.Sources.SourceName,
    SUM((OrderDetails.Quantity * OrderDetails.UnitPrice)) + Orders.DeliveryCharge - ((SUM((OrderDetails.Quantity * OrderDetails.UnitPrice)) + Orders.DeliveryCharge) * Orders.Discount / 100) AS Amount,
    ReceivedOrders.ReceivingDate
  FROM dbo.Orders
  INNER JOIN dbo.Customers
    ON dbo.Orders.CustomerID = dbo.Customers.CustomerID
  INNER JOIN dbo.Outlets
    ON dbo.Orders.OutletID = dbo.Outlets.OutletID
  INNER JOIN dbo.Users
    ON dbo.Orders.UserID = dbo.Users.UserID
  INNER JOIN dbo.Sources
    ON dbo.Orders.SourceID = dbo.Sources.SourceID
  INNER JOIN dbo.OrderDetails
    ON dbo.OrderDetails.OrderID = dbo.Orders.OrderID
  INNER JOIN dbo.Brands
    ON dbo.Brands.BrandID = dbo.Outlets.BrandID
  INNER JOIN dbo.Areas
    ON dbo.Areas.AreaID = dbo.Customers.AreaID
  LEFT JOIN dbo.ReceivedOrders
    ON dbo.ReceivedOrders.OrderID = dbo.Orders.OrderID
  WHERE  BETWEEN OrderDate AND DATEADD(HOUR, 16, OrderDate) and OrderDate=GETDATE()
  GROUP BY dbo.Orders.OrderID,
           dbo.Orders.OrderStatus,
           dbo.Customers.CustomerName,
           dbo.Customers.CustomerID,
           dbo.Customers.Phone,
           dbo.Customers.Mobile,
           dbo.Orders.OrderDate,
           dbo.Outlets.OutletName,
           dbo.Users.FirstName,
           dbo.Users.LastName,
           dbo.Sources.SourceName,
           dbo.Orders.DeliveryCharge,
           Orders.Discount,
           dbo.Brands.BrandName,
           dbo.Areas.AreaName,
           ReceivedOrders.ReceivingDate
  ORDER BY dbo.Orders.OrderID
  </code></pre>