0
good afternoon. All right? I’m trying to print a loop of hours where Data10 should show start date + 10 seconds and Data5 should show start date + 5 minutes I tried the down loop without success:
declare @DataInicial DATETIME, @DataFinal DATETIME, @Data10 DATETIME, @Data5 DATETIME;
SET @DataInicial = '2020-06-19 23:35:00.000'
SET @DataFinal = '2020-06-19 23:56:00.000'
WHILE @DataInicial<= '2020-06-19 23:56:00.000'
BEGIN
IF @DataInicial > '2020-06-19 23:56:00.000'
BEGIN
BREAK
END
set @Data10 = DATEADD(SECOND,10,@DataInicial)
set @Data5 = DATEADD(MINUTE,5,@DataInicial)
select @Data10, @Data5
END;
The same shows as a result several times:
2020-06-19 23:35:10.000 | 2020-06-19 23:40:00.000
2020-06-19 23:35:10.000 | 2020-06-19 23:40:00.000
2020-06-19 23:35:10.000 | 2020-06-19 23:40:00.000
Could you signal me the error in mounted manure? Abs!