Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

sql find gaps in date ranges

-- Range of missing dates d in table t1
SELECT * FROM (
    SELECT 
  		trunc(d) AS d,
        (SELECT min(trunc(d)) FROM t1 t2 WHERE trunc(t2.d) > trunc(t1.d)) next_d
    FROM t1
) WHERE d <> next_d - 1;
 
PREVIOUS NEXT
Tagged: #sql #find #gaps #date #ranges
ADD COMMENT
Topic
Name
5+6 =