Created
October 22, 2022 16:24
-
-
Save samyakrt/5a79712e0e22d989a0a9c7c73dfc05ba to your computer and use it in GitHub Desktop.
generate time series between specified months
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH RECURSIVE dates_without_gaps(month) AS ( | |
SELECT | |
DATE_SUB('2022-10-15', INTERVAL 1 YEAR) as month | |
UNION ALL | |
SELECT | |
DATE_ADD(month, INTERVAL 1 MONTH) as month | |
FROM | |
dates_without_gaps | |
WHERE | |
month < '2022-10-15' | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment