generate_series : how to remove or no generate the last one
CREATE OR REPLACE FUNCTION slots(start_date TIMESTAMP, end_date TIMESTAMP, delay INTERVAL) RETURNS SETOF TIMESTAMP AS $$
BEGIN
RETURN QUERY SELECT * FROM generate_series(start_date, end_date - delay, delay);
END
$$
LANGUAGE plpgsql;


Last timeslot is not generated even it is partial (not empty at all) - i.e. 

SELECT slots('2019-12-19 10:00', '2019-12-19 12:10', '30 mins')


will not generate '2019-12-19 12:00' timeslot because it has 10 mins length.

If such partial timeslot must be generated, then substract '1 second'::interval instead of delay from end_date.