Re: Last Day Last Month - Query Assistance

On Jul 31, 7:36 pm, master44 <trp..._at_gmail.com> wrote:
> I put a query together to pull the last day of last month that has> worked fine for the last 2 months, but suddenly failed today now that> the date is the 31st of the month:>> SELECT TO_DATE(TO_CHAR(LAST_DAY(SYSDATE + numtoyminterval(-1,> 'MONTH')), 'YYYY-MM-DD'), 'YYYY-MM-DD') FROM DUAL>> What am I doing wrong??>> Eunning this against a Oracle 10G database, sorry don't know the exact> version.

You are trying too hard.

TRUNC(SYSDATE,'MM") returns the first day of the current month. The
last day of last month is one less than the first day of the current
month. Therefore, you will need:
SELECT
TRUNC(SYSDATE,'MM')-1
FROM
DUAL;
TRUNC(SYS