79741001

Date: 2025-08-20 11:31:11
Score: 1
Natty:
Report link

I did something similar to @Rono using table variable, where I inserted and sorted my data by date.
I am supposed to ensure date continuity (no gaps, gap exactly 1 day)
maybe it will inspire someone

declare @sorted table (num int identity, id int, dfrom date, dto date)

insert into @sorted(id, dfrom, dto)
values
(1230, '2024-01-01','2024-01-15'),
(4567, '2024-01-16','2024-10-30'),
(9000, '2024-10-31','2024-12-31'),
(9001, '2025-01-01','2025-01-15'),
(9015, '2025-01-16','2025-06-30'),
(9592, '2025-07-01','3000-01-01')

select  s.id
from    @sorted s
left join 
(
    select id, dfrom, dto, num from @sorted
) sub
    on sub.num = s.num + 1
where 
    datediff(day, s.dto, sub.dfrom) <> 1
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @Rono
  • Low reputation (1):
Posted by: XzajoX