to_date中的日期格式错误

时间:2018-04-02 09:55:40

标签: sql function to-date

我尝试运行此查询:

选择

   to_date(substr( "SCC_STG_DIM_OVERWRITE_FNL"."TERM_END_DT" , 1, 19), 'yyyy.mm.dd hh24:mi:ss.aaaaaaaaa') 

                                                        FROM ("EDMWHS"."SERVICE_CONTRACT" "SERVICE_CONTRACT" INNER JOIN "EDMSTG"."STG_SERVICE_CONTR_DELTA" "STG_SERVICE_CONTR_DELTA" ON
                                                        ( "STG_SERVICE_CONTR_DELTA"."CRM_ORDER_OBJECT_GUID"  =  "SERVICE_CONTRACT"."CRM_ORDER_OBJECT_GUID" )) INNER JOIN
                                                        "EDMSTG"."SCC_STG_DIM_OVERWRITE_FNL" "SCC_STG_DIM_OVERWRITE_FNL" ON ( "SCC_STG_DIM_OVERWRITE_FNL"."CRM_ORDER_OBJECT_GUID"  = 
                                                        "SERVICE_CONTRACT"."CRM_ORDER_OBJECT_GUID" )
                                                        WHERE ( "SCC_STG_DIM_OVERWRITE_FNL"."RECORD_STATUS"  = 'A') and ( "SERVICE_CONTRACT"."RECORD_STATUS"  = 'A')
                                                        ORDER BY  "SERVICE_CONTRACT"."CRM_ORDER_OBJECT_GUID"  ASC ,  "SCC_STG_DIM_OVERWRITE_FNL"."CRM_ORDER_ITEM_GUID"  ASC ; 

但我收到以下错误: ORA-01821: date format not recognized 01821. 00000 - "date format not recognized

为什么我会收到此错误,我该如何解决?

1 个答案:

答案 0 :(得分:0)

我相信你想要:

select to_timestamp('2016-01-01 14:08:13.123456789', 'yyyy.mm.dd hh24:mi:ss.ff9')
from dual;

您的代码有两个错误。小数秒由ff表示,而不是aa。并且,to_date()不支持小数秒,因此您可能打算to_timestamp()