Skip to content

Instantly share code, notes, and snippets.

@trietphm
Last active October 3, 2017 07:11
Show Gist options
  • Save trietphm/6a404a61ed372d06a860b9a0d0a66135 to your computer and use it in GitHub Desktop.
Save trietphm/6a404a61ed372d06a860b9a0d0a66135 to your computer and use it in GitHub Desktop.
Generate date in range
WITH time_range AS (
select generate_series('2015-12-31 00:00:00', '2016-12-31 00:00:00', '1 day'::interval) AS day_d
),
select generate_series(CAST((NOW() + INTERVAL '-30 day') AS date), CAST((NOW() + INTERVAL '-0 day') AS date), '1 day'::interval) AS day_d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment