Oracle 时区日期格式掩码是什么?
我需要从外部源插入日期格式,其中包括时区的三个字母代码,但 TZD 格式掩码似乎不起作用...
insert into blah
values (to_date('Thu, 18 Feb 2010 08:37:00 EST','Dy, DD Mon YYYY HH24:MI:SS TZD'));
ORA-01821: date format not recognized
如果我删除“TZD”.. ?
insert into blah
values (to_date('Thu, 18 Feb 2010 08:37:00','Dy, DD Mon YYYY HH24:MI:SS'));
1 row created.
Oracle 中此类插入语句的正确掩码是什么
desc blah
Name Null? Type
----------------------------------------- -------- ----------------------------
D DATE
编辑:我将表列从 DATE 类型更改为 TIMESTAMP 类型并得到相同的错误。
I need to insert a date format from an outside source which includes the three letter code for time zone, but the TZD formatting mask does not seem to work...
insert into blah
values (to_date('Thu, 18 Feb 2010 08:37:00 EST','Dy, DD Mon YYYY HH24:MI:SS TZD'));
ORA-01821: date format not recognized
If I remove the "TZD"...
insert into blah
values (to_date('Thu, 18 Feb 2010 08:37:00','Dy, DD Mon YYYY HH24:MI:SS'));
1 row created.
What is the proper mask for such an insert statement in Oracle?
desc blah
Name Null? Type
----------------------------------------- -------- ----------------------------
D DATE
Edit: I changed the table column from DATE type to TIMESTAMP type and got the same error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
日期列没有时区选项。您必须将列创建为数据类型
TIMESTAMP WITH TIME ZONE
或TIMESTAMP WITH LOCAL TIME ZONE
,此外,TO_DATE
函数不会不理解您正在应用的时区格式掩码。Date columns don't have timezone as an option. You'd have to create the column as data type
TIMESTAMP WITH TIME ZONE
orTIMESTAMP WITH LOCAL TIME ZONE
, and besides, theTO_DATE
function doesn't understand the TIME ZONE format mask you're applying.如果时区与您无关,只需使用 SUBSTR 函数将其从字符串中删除,然后按照第二个示例中的方式插入。
If timezone is not relevant for you, just strip it from the string using SUBSTR function and insert as in your second example.