Skip to content

Instantly share code, notes, and snippets.

@ajlai
Created February 9, 2015 20:09
Show Gist options
  • Save ajlai/0b5d7ae33d2c22b131f5 to your computer and use it in GitHub Desktop.
Save ajlai/0b5d7ae33d2c22b131f5 to your computer and use it in GitHub Desktop.
Date series on redshift
WITH date_series_bounds AS (
SELECT date('2012-12-21') as start, date('2013-08-23') as end
), date_series AS (
select date(days.start + days.interval)
from (
select bounds.start, generate_series(0, bounds.end - bounds.start) AS interval from date_series_bounds bounds
) as days
)
select * from date_series
-- 2012-12-21
-- 2012-12-22
-- ...
-- 2013-08-22
-- 2013-08-23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment