Created
July 2, 2012 02:20
-
-
Save slattery/3030549 to your computer and use it in GitHub Desktop.
Find the next occurence of a day of the week in postgresql
This file contains hidden or 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
-- I'd gladly pay you Tuesday for a hamburger today! | |
-- OK, see you next Tuesday. | |
SELECT * | |
FROM generate_series | |
( | |
current_date + '1 day'::interval, -- in case now() is same dow | |
current_date + '7 days'::interval, | |
'1 day' | |
) as s(a) | |
WHERE | |
(select EXTRACT(ISODOW FROM s.a)) = '2'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment