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_DATELAST_DAY_OF_MONTHFIRST_DAY_OF_NEXT_MONTH
02.Feb.2019 09:32:0028.Feb.2019 09:32:0001.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.

Similar Reads

Date and Time Functions in PL/SQL

There are many useful Date and Time functions in PL/SQL. A table of such functions along with their description is given below:...

SYSDATE Function

The SQL SYSDATE function returns the current date and time set for operating system on which the database resides....

EXTRACT() Function

Oracle helps you to extract Year, Month, and Day from a date using the Extract() Function....

ADD_MONTHS () Function

Using this method in PL/SQL you can add as well as subtract a number of months(n) to a date. Here ‘n’ can be both negative or positive....

LAST_DAY() Function

Using this method in PL/SQL you can get the last day in the month of specified date....

MONTHS_BETWEEN () Function

Using this method in PL/SQL you can calculate the number of months between two entered dates date1 and date2. if date1 is later than date2 then the result would be positive and if date1 is earlier than date2 then result is negative....

NEXT_DAY() Function

It will return the upcoming date of the first weekday that is later than the entered date.It has two parameters first date where, system date or specified date can be entered; second day of week which should be in character form....