在程序中比较日期时收到“ora-01481:无效的数字格式模型”

问题描述 投票:0回答:1

我有一个查询,我正在比较两个日期以获取数据。以下是相同的查询:

SELECT CIRCLE, MPNAME AS ITEM,
  ROUND(SUM(INTER_FSA_UG),2) INTER_UG, ROUND(SUM(INTER_FSA_AERIAL),2) INTER_AR,
  ROUND(SUM(INTRA_FSA_UG),2) INTRA_UG, ROUND(SUM(INTRA_FSA_AERIAL),2) INTRA_AR,
  ROUND(SUM(ENTER_FSA_UG),2) ENTER_UG, ROUND(SUM(ENTER_FSA_AERIAL),2) ENTER_AR
   FROM (
   SELECT CIRCLE, MAINTENANCEZONENAME AS MPNAME,  
      SUM(case when SPAN_TYPE= 'INTERCITY' then NE_LENGTH else 0 end )as INTER_NE_LENGTH ,
      SUM(case when SPAN_TYPE= 'INTRACITY' then NE_LENGTH else 0 end )as INTRA_NE_LENGTH,
      SUM(case when SPAN_TYPE= 'ENTERPRISE' then NE_LENGTH else 0 end )as ENTER_NE_LENGTH,
     
      SUM(case when SPAN_TYPE= 'INTERCITY' then FSA_UG else 0 end )as INTER_FSA_UG,
      SUM(case when SPAN_TYPE= 'INTRACITY' then FSA_UG else 0 end )as INTRA_FSA_UG,
      SUM(case when SPAN_TYPE= 'ENTERPRISE' then FSA_UG else 0 end )as ENTER_FSA_UG,
     
      SUM(case when SPAN_TYPE= 'INTERCITY' then FSA_AERIAL else 0 end )as INTER_FSA_AERIAL,
      SUM(case when SPAN_TYPE= 'INTRACITY' then FSA_AERIAL else 0 end )as INTRA_FSA_AERIAL,
      SUM(case when SPAN_TYPE= 'ENTERPRISE' then FSA_AERIAL else 0 end )as ENTER_FSA_AERIAL
      FROM TBL_FIBER_INV_SIGN_OFF_SHEET_H
      WHERE
      UPPER(CIRCLE) = UPPER(STATENAME) 
      --HOTOOFFERDATE >= TO_DATE('11'||PHOTODATE,'DDMMYYYY')  TO_DATE('11-04-23','DD-MM-YY');
      AND TO_CHAR( TO_DATE(HOTOOFFERDATE,'DD-MM-YY, HH:MI:SS') ,'MMYYYY') = TO_CHAR(PHOTODATE,'MMYYYY')  // here is the error
      GROUP BY CIRCLE, MAINTENANCEZONENAME, SPAN_TYPE
      ORDER BY MAINTENANCEZONENAME
      ) GROUP BY CIRCLE, MPNAME ORDER BY MPNAME;

注意 我的

HOTOOFFERDATE
是 DATE 数据类型,
PHOTODATE
是 NVARCHAR2。

导致错误的原因是什么以及如何修复它?

oracle-database stored-procedures
1个回答
0
投票

尝试 TO_CHAR(TO_DATE(HOTOOFFERDATE,'DD-MM-YY, HH:MI:SS') ,'MMYYYY') = TO_CHAR(TO_DATE(PHOTODATE,'DD-MM-YY'),'MMYYYY')

© www.soinside.com 2019 - 2024. All rights reserved.