Getting previous Days Data

09/19/2012


09/20/2012



1/19/2011
1/19/2011
1/19/2011

Yes im in USA
 
Hi again,

Formatdate was not a true date/time value, because of the missing zero at the beginning, I think using Datediff was converting it into date/time for you.

Hopefully the following code is correct:


SELECT *
FROM bk_vAPTData
Where
convert
(datetime,formatdate,101)
BETWEEN convert(varchar(10),dateadd(D,-1,getdate()),101) AND convert(varchar(10),getdate(),101)
 
That worked thanks.
 
NM that didnt work. It worked until we started adding records in the table for todays date 9-21-12.
 
SQL_Hell may have gone to the pubs across the pond there. If your field truly contains no time component, try

WHERE convert(datetime,formatdate,101) = convert(varchar(10),dateadd(D,-1,getdate()),101)
 

Users who are viewing this thread

Back
Top Bottom