문제

I am trying to format a date:

FORMAT(table.TCKT.TCKT_ISS_DATE, 'YYYY') AS TICKETYEAR

but I am getting the following error:

ORA-00904: "FORMAT": invalid identifier

Right now the date show the complete timestamp. Any suggestions on how to fix this problem, or any other way to format the date to just show the four digit year?

도움이 되었습니까?

해결책

Use this function:

TO_CHAR(table.TCKT.TCKT_ISS_DATE, 'YYYY') AS TICKETYEAR 

다른 팁

You want to use TO_CHAR instead of FORMAT here, like this:

TO_CHAR(table.TCKT.TCKT_ISS_DATE, 'YYYY') AS TICKETYEAR

Oracle uses TO_CHAR for string casting, you can see here for additional format options.

There's also the option of using EXTRACT() which is ANSI-standard and portable:

EXTRACT(YEAR FROM table.TCKT.TCKT_ISS_DATE) AS ticketyear
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top