Get Previous One Day Data in Sql Server

Get Previous One Day Data in Sql Server using convert(), dateadd(), datediff() and getdate() sql functions and between operator.

SELECT OrderID,CustomerID, OrderDateTime
FROM [DEMODB].[dbo].[Orders]
WHERE OrderDateTime  
      BETWEEN CONVERT (VARCHAR(10), 
         DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), -1), 101) +' '+ '00:00:00'
      AND CONVERT (VARCHAR(10), 
         DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), -1), 101) +' '+ '23:59:59'

Comments

Popular posts from this blog

Login with facebook using coldfusion

Create CSV file in Coldfusion Using CFFile