LAST_DAY() Function
Using this method in PL/SQL you can get the last day in the month of specified date.
LAST_DAY() Function Example
Query:
SELECT SYSDATE AS CURRENT_DATE, LAST_DAY(SYSDATE) AS LAST_DAY_OF_MONTH,
LAST_DAY(SYSDATE)+1 AS FIRST_DAY_OF_NEXT_MONTH
FROM Dual
Output:
CURRENT_DATE | LAST_DAY_OF_MONTH | FIRST_DAY_OF_NEXT_MONTH |
---|---|---|
02.Feb.2019 09:32:00 | 28.Feb.2019 09:32:00 | 01.Mar.2019 09:32:00 |
Explanation: In above example, we are getting current date using SYSDATE function and last date of the month would be retrieved using LAST_DAY function and this function be also helpful for retrieving the first day of the next month.
Date and Time Functions in PL/SQL
Date and Time Functions in PL/SQL are useful for date and time operations like extracting date components, performing date arithmetic, and converting between date formats.