You can select the last day of month.
SELECT (date_trunc('MONTH', ('201608'||'01')::date) + INTERVAL '1 MONTH - 1 day')::DATE;
201608 is replaceable with a variable.
201608