generate_series : how to remove or no generate the last one I use this function for generating time slots. It's work well. But, there is a little problem. 

My business opens at 10:00 and close at 12:00.

-- generate slots

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::timestamp, end_date, delay);
END
$$
LANGUAGE plpgsql;


-- call the function

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


-- Results

2019-12-19 10:00:00
2019-12-19 10:30:00
2019-12-19 11:00:00
2019-12-19 11:30:00
2019-12-19 12:00:00


As you can see, the last generated slot is not available, because of my business close at 12:00. How can i remove or not generate this 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.