Skip Headers
Oracle® Database SQL Language Reference
11g Release 2 (11.2)

Part Number E10592-04
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

LAST_DAY

Syntax

Description of last_day.gif follows
Description of the illustration last_day.gif

Purpose

LAST_DAY returns the date of the last day of the month that contains date. The last day of the month is defined by the session parameter NLS_CALENDAR. The return type is always DATE, regardless of the data type of date.

Examples

The following statement determines how many days are left in the current month.

SELECT SYSDATE,
   LAST_DAY(SYSDATE) "Last",
   LAST_DAY(SYSDATE) - SYSDATE "Days Left"
   FROM DUAL;
 
SYSDATE   Last       Days Left
--------- --------- ----------
30-MAY-01 31-MAY-01          1

The following example adds 5 months to the hire date of each employee to give an evaluation date:

SELECT last_name, hire_date, TO_CHAR(
   ADD_MONTHS(LAST_DAY(hire_date), 5)) "Eval Date"
   FROM employees;

LAST_NAME                 HIRE_DATE Eval Date
------------------------- --------- ---------
King                      17-JUN-03 30-NOV-03
Kochhar                   21-SEP-05 28-FEB-05
De Haan                   13-JAN-01 30-JUN-01
Hunold                    20-MAY-08 31-OCT-08
Ernst                     21-MAY-07 31-OCT-07
Austin                    25-JUN-05 30-NOV-05
Pataballa                 05-FEB-06 31-JUL-06
Lorentz                   07-FEB-07 31-JUL-07
. . .