문제

I'm running this SQL code.

select  to_char(to_date('14-05-13','yyyy-mm-dd'),'yyyy') from dual;

I don't know why oracle returns 0014 for me.

Could someone help me?

도움이 되었습니까?

해결책 2

you can replace YYYY to RRRR

select to_char(to_date('14-05-13','rrrr-mm-dd'),'rrrr') from dual;

다른 팁

You are giving it "yyyy-mm-dd" for a date format, but you are giving it a date of "14-05-13". So, you are literally telling it that the date is 5/13/0014.

Try either:

select to_char(to_date('14-05-13','yy-mm-dd'),'yyyy') from dual

or preferably:

select to_char(to_date('2014-05-13','yyyy-mm-dd'),'yyyy') from dual;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top