oracle ORA-00904: "FORMAT": 无效标识符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2715684/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ORA-00904: "FORMAT": invalid identifier
提问by gary A.K.A. G4
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
ORA-00904: "FORMAT": 无效标识符
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?
现在日期显示完整的时间戳。关于如何解决此问题的任何建议,或任何其他方式来格式化日期以仅显示四位数年份?
回答by RedFilter
Use this function:
使用这个功能:
TO_CHAR(table.TCKT.TCKT_ISS_DATE, 'YYYY') AS TICKETYEAR
回答by Nick Craver
You want to use TO_CHAR
instead of FORMAT
here, like this:
你想使用TO_CHAR
而不是在FORMAT
这里,像这样:
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.
OracleTO_CHAR
用于字符串转换,您可以在此处查看其他格式选项。
回答by David Faber
There's also the option of using EXTRACT()
which is ANSI-standard and portable:
还可以选择使用EXTRACT()
哪个是 ANSI 标准且可移植的:
EXTRACT(YEAR FROM table.TCKT.TCKT_ISS_DATE) AS ticketyear