Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select date::date
- from generate_series(format('%s-%s-%s', syear, 6, 1)::date,
- format('%s-%s-%s', syear + 1, 5, 31)::date,
- '1 day'::interval) date;
- CREATE OR REPLACE FUNCTION myCycle(syear integer)
- RETURNS TABLE(sdate date) AS $$
- BEGIN
- RETURN QUERY
- select date::date
- from generate_series(format('%s-%s-%s', syear, 6, 1)::date,
- format('%s-%s-%s', syear + 1, 5, 31)::date,
- '1 day'::interval) date;
- END;
- $$ LANGUAGE plpgsql;
- select c.sdate, ot.other_fields
- from myCycle(2015) c
- inner join other_table ot
- on c.sdate = ot.date;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement