LAST_DAY function in Oracle

In Oracle SQL, you can use the built-in LAST_DAY function.

✅ If you have a date like '01-DEC-2025'

SELECT LAST_DAY(TO_DATE('01-DEC-2025','DD-MON-YYYY')) AS LAST_DATE
FROM dual;

✅ Output

31-DEC-2025

🔹 If the column is already DATE datatype

SELECT LAST_DAY(your_date_column)
FROM your_table;

🔹 If the column is VARCHAR2

SELECT LAST_DAY(TO_DATE(your_column,'DD-MON-YYYY'))
FROM your_table;

🔹 To display in specific format

SELECT TO_CHAR(
         LAST_DAY(TO_DATE('01-DEC-2025','DD-MON-YYYY')),
         'DD-MON-YYYY'
       ) AS LAST_DATE
FROM dual;


Post a Comment

And that's all there is to it!

If anyone has any other questions or requests for future How To posts, you can either ask them in the comments or email me. Please don't feel shy at all!

I'm certainly not an expert, but I'll try my hardest to explain what I do know and research what I don't know.

Previous Post Next Post