sql server - Is this SQL line saying previous day or the next day? -
we have old sql script looks data previous day. in our table have dateplaced column, want able records time ran til previous day. help.
where datediff(day,[dateplaced],getdate()) = 1
ugh, don't way. applying function column means index relatively useless. data yesterday (or range, matter), try:
declare @today date = sysdatetime(); ... dateplaced >= dateadd(day, -1, @today) , dateplaced < @today;
if on old version sql server 2005, instead:
declare @today datetime; set @today = datediff(day, 0, getdate()); ... dateplaced >= dateadd(day, -1, @today) , dateplaced < @today;
Comments
Post a Comment