I'm using Postgres and I would like to find missing ranges of dates. I've got this table with these data :
create table event_dates(date)AS VALUES('2024-12-09'::date)
,('2024-12-13')
,('2024-12-20');
I would like to find the number of missing periods in an arbitrary range. For example, between 2024-12-05 and 2024-12-25 I would like the result to be 4, because :
- no dates between
2024-12-05and2024-12-09(first gap) - no dates between
2024-12-09and2024-12-13(second gap) - no dates between
2024-12-13and2024-12-20(third gap) - no dates between
2024-12-20and2024-12-25(fourth gap)
I can't get it work with any window function.
