postgresql SELECT the last day of month


Example

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.