Notice
Recent Posts
«   2025/12   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Archives
Today
Total
관리 메뉴

IT'S YU

[Oracle] LAST_DAY() 함수 - 특정 달의 마지막 날짜 구하기 본문

DB/Oracle

[Oracle] LAST_DAY() 함수 - 특정 달의 마지막 날짜 구하기

자석 2022. 2. 23. 15:49

오라클 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

 

출처 : https://web-obj.tistory.com/403