Well, your DTE is NOT a datetime, so your conversion routing is not doing anything: Prrof:DECLARE @Input varchar(10)DECLARE @Yesterday as nvarchar (8);set @Input = '20080522'set @Yesterday = (replace(CONVERT(VarChar(10), DATEADD(d, -1, getdate()), 101), '/', ''))SELECT @Yesterday, replace(CONVERT(VarChar(10), @Input,101), '/', '')
RETURNS:05222008 20080522You can EITHER change your comparison on the column (not advised):DECLARE @Input varchar(10)DECLARE @Yesterday as nvarchar (8);set @Input = '20080522'set @Yesterday = (replace(CONVERT(VarChar(10), DATEADD(d, -1, getdate()), 101), '/', ''))SELECT @Yesterday, replace(CONVERT(VarChar(10), convert(datetime,@Input),101), '/', '')
OR on the VARIABLE (advised):DECLARE @Input varchar(10)DECLARE @Yesterday as nvarchar (8);set @Input = '20080522'set @Yesterday = (replace(CONVERT(VarChar(10), DATEADD(d, -1, getdate()), 111), '/', ''))SELECT @Yesterday, @Input
You'll need to add in your select form, I've just shown you variables for comparisons*##* *##* *##* *##* Chaos, Disorder and Panic ... my work is done here!