Skip to content

Instantly share code, notes, and snippets.

@certainty
Created December 6, 2012 09:44
Show Gist options
  • Save certainty/4223296 to your computer and use it in GitHub Desktop.
Save certainty/4223296 to your computer and use it in GitHub Desktop.
sql
WITH RECURSIVE dates as
( SELECT NOW() AS day
UNION ALL
SELECT day + interval '1 day'
FROM dates
WHERE day + interval '1 day' <= '2012-12-24'
)
SELECT day FROM dates
LEFT OUTER JOIN DailyData ON dates.day = DailyData.date
WHERE DailyData.id IS NULL
ORDER BY dates.day ASC
LIMIT 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment