I need to nightly run a report at 1am for all the customers who visited the hotel yesterday. I am not understanding what I am doing wrong. I am trying as below but it doesn't give me any records. CheckInDate format is '2015-09-02 06:45:00.000'. Please assist. Thanks.
Select top 5 * from Customers where CheckInDate = DATEADD(day, -1, GETDATE())
Below worked:
select top 5 * from Customers where cast(CheckInDate as date) = DATEFROMPARTS(YEAR(GETDATE()-1), MONTH(GETDATE()-1), DAY(GETDATE()-1))