Hi,You're assuming that the dateformat you entered is understood by SQL Server. First Try This:DECLARE @firstint DateTimeDECLARE @secondint DateTimeSET @firstint = 01/05/2012SET @secondint = 01/06/2012PRINT @FirstIntWHILE @firstint < @secondintBEGIN PRINT @firstint SET @firstint = @firstint + 1END
You'll see that the first date is interpreted as 01-01-1900Then, try this one:SET DATEFORMAT DMYDECLARE @firstint DateTimeDECLARE @secondint DateTimeSET @firstint = '01/05/2012'SET @secondint = '01/06/2012'WHILE @firstint < @secondintBEGIN PRINT @firstint SET @firstint = @firstint + 1END
Succes