Question : get yesterdays date

I am trying to find all date submitted yesterday based on a field [Created], is this code the correct way to do that?

SELECT     Title, [Material Number], [Business Group], ROHS2_STATUS, [Work e-mail], Created
FROM         dbo.ROHS_TRANSLATION_REPORT
WHERE     (Created = DATEADD(day, 1, GETDATE()))

Answer : get yesterdays date

this will do:

SELECT     Title, [Material Number], [Business Group], ROHS2_STATUS, [Work e-mail], Created
FROM         dbo.ROHS_TRANSLATION_REPORT
WHERE     Created >= DATEADD(day, -1, convert(datetime, convert(varchar(10),GETDATE(), 120), 120))
  AND Created < convert(datetime, convert(varchar(10),GETDATE(), 120), 120)


the double convert is to remove the time portion
Random Solutions  
 
programming4us programming4us