将 DATETIME 从 C# 插入 Oracle DB 时,格式代码出现两次错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16094747/
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
format code appears twice error while inserting DATETIME from C# to Oracle DB
提问by user545359
I am facing the below oracle error for the query
我正面临查询的以下 oracle 错误
Insert Query:
插入查询:
INSERT INTO WINBACK_REFERRAL_CODES
(REFERRAL_CODE, IS_DELETED, CREATED_BY,
CREATED_DT,
MODIFIED_BY,
MODIFIED_DT, DELETED_BY, DELETED_DT)
values
('sfsdfsd', 'N', 'LA\a03789',
To_date('4/18/2013 3:57:47 PM','MM/DD/YYYY HH12:MI:SS AM'),
'',
To_date('','MM/DD/YYYY HH12:MI:SS AM'),
'',
To_date('4/18/2013 3:57:47 PM','MM/DD/YYYY HH12:MM:SS AM'));
ERROR MESSAGE:
错误信息:
Can someone please help me resolving this issue. I am trying to insert date and time in this format 4/18/2013 3:57:47 PMto oracle DB.
有人可以帮我解决这个问题。我正在尝试以这种格式将日期和时间插入到 oracle DB 4/18/2013 3:57:47 PM。
回答by aquaraga
To_date('4/18/2013 3:57:47 PM','MM/DD/YYYY HH12:MM:SS AM')
should be rewritten to To_date('4/18/2013 3:57:47 PM','MM/DD/YYYY HH12:MI:SS AM')
. Note the change from MM to MI.
To_date('4/18/2013 3:57:47 PM','MM/DD/YYYY HH12:MM:SS AM')
应该改写为To_date('4/18/2013 3:57:47 PM','MM/DD/YYYY HH12:MI:SS AM')
. 注意从 MM 到 MI 的变化。