Oracle에서 날짜에서 월 이름을 가져옵니다.
Oracle에서 지정된 날짜에서 월 이름을 가져오는 방법은 무엇입니까?
지정된 날짜가'15-11-2010'그럼 나는 원한다November이 날짜부터.
select to_char(sysdate, 'Month') from dual
이 예에서는 다음과 같습니다.
select to_char(to_date('15-11-2010', 'DD-MM-YYYY'), 'Month') from dual
이거 드셔보세요.
select to_char(sysdate,'dd') from dual; -> 08 (date)
select to_char(sysdate,'mm') from dual; -> 02 (month in number)
select to_char(sysdate,'yyyy') from dual; -> 2013 (Full year)
to_char(mydate, 'MONTH')그 일을 할 수 있을 거야
Oracle(11g 이상) 데이터베이스:
치면
select to_char(SYSDATE,'Month') from dual;
형식화되지 않은 월 이름을 공백과 함께 지정합니다.May는 May로 지정될 것이다.문자열 May에는 공백이 있습니다.
월 이름 형식을 지정하려면(예: 공간을 자르기 위해)
select to_char(SYSDATE,'fmMonth') from dual;
그러면 'May'가 반환됩니다.
필드에서 값을 가져오려는 경우 다음을 사용할 수 있습니다.
select extract(month from [field_name])
from [table_name]
위의 "월" 추출 값에 일 또는 년을 삽입할 수도 있습니다.
시스템 날짜를 가져오는 경우:
--Full month name :
select to_char(trunc(sysdate,'MONTH'),'MONTH') as month from dual; --MARCH
--Short month name:
select to_char(trunc(sysdate,'MON'),'MON') as month from dual; --MAR
--Month number:
select to_char(trunc(sysdate,'MM'),'MM') as month from dual; --03
특정 날짜를 지정할 경우:
--Full month's name:
select to_char(trunc(to_date('11-03-2021','DD-MM-YYYY'),'MONTH'),'MONTH') as month from dual; --MARCH
--Short month's name:
select to_char(trunc(to_date('11-03-2021','DD-MM-YYYY'),'MON'),'MON') as month from dual; --MAR
--Month's number:
select to_char(trunc(to_date('11-03-2021','DD-MM-YYYY'),'MM'),'MM') as month from dual; --03
이거 드셔보세요
select to_char(SYSDATE,'Month') from dual;
풀네임으로 한번 해보세요.
select to_char(SYSDATE,'Mon') from dual;
줄여서
자세한 옵션은 이쪽에서 확인하실 수 있습니다.
https://www.techonthenet.com/oracle/functions/to_char.php
언급URL : https://stackoverflow.com/questions/4497456/get-month-name-from-date-in-oracle
'programing' 카테고리의 다른 글
| 컴포넌트의 Reactjs 비동기 렌더링 (0) | 2023.03.11 |
|---|---|
| Oracle 9i에서 빈 문자열을 NULL로 취급하는 이유는 무엇입니까? (0) | 2023.03.06 |
| 브라우저는 언제 Javascript를 실행합니까?실행 커서는 어떻게 이동합니까? (0) | 2023.03.06 |
| Spring Cloud Eureka Server 자체 보존 및 갱신 임계값 이해 (0) | 2023.03.06 |
| RestTemplate를 사용할 때 내부 잭슨 매퍼를 설정하려면 어떻게 해야 합니까? (0) | 2023.03.06 |