How to get current month firstdate and lastdate in postgres sql query

suresh picture suresh · Apr 14, 2017 · Viewed 10.9k times · Source

I want to get first and last dates of current month (Like 30th or 31st).How to get this one by using postgress sql query.

Answer

user157251 picture user157251 · Apr 14, 2017

First day is easy...

SELECT date_trunc('month', CURRENT_DATE);

Last day isn't much more difficult either.

SELECT date_trunc('month', CURRENT_DATE) + interval '1 month - 1 day';