I have a series of tables partitioned by dates and named in the following format:
public.schedule_20121018
Is there a way to generate a sequence of dates in the above 20121018 pattern so that I can do a for loop SELECT through information_schema.tables?
For now I've got
SELECT * FROM information_schema.tables
WHERE table_type = 'BASE TABLE'
AND table_schema = 'public'
AND table_name like 'schedule_%'
ORDER BY table_name;
But for instance I need the last 7 days' record so that a date sequence shall be starting from 20121012 to 20121018. Thanks!