Reputation: 1517
I thought this would work but its not bring back any results:
some sql statement....
AND (DateDiff(Day, irs.timeStamp, GETDATE()) = 1)
It brings back all the results for today if I change the result to 0 but not for yesterday if I change it to 1 or -1?
Upvotes: 0
Views: 4099
Reputation: 280262
You should use an open-ended range, e.g. to get all data from yesterday, you want everything equal to or after midnight but before midnight today.
AND irs.timeStamp >= CONVERT(DATE, DATEADD(DAY, -1, GETDATE()))
AND irs.timeStamp < CONVERT(DATE, GETDATE());
Upvotes: 5