DB/ORACLE
ORACLE LAST_DAY()
yeon.Biju
2020. 4. 6. 14:45
오라클 LAST_DAY()
LAST_DAY()
- 달의 마지막 날짜를 구해준다.
LAST_DAY(date)
의 형태
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.
SQL> SELECT LAST_DAY(SYSDATE) FROM DUAL ;
--> 2020/04/30 오후 2:42:01
SQL> SELECT LAST_DAY('2020-04-01') FROM DUAL;
--> ORA-01861: literal does not match format string
SQL> SELECT LAST_DAY(TO_DATE('2020-04-01', 'YYYY-MM-DD')) FROM DUAL;
--> 2020/04/30
SQL> SELECT TO_CHAR(LAST_DAY(SYSDATE), 'YYYY-MM-DD') FROM DUAL ;
--> 2020-04-30