简体   繁体   English

如何使用此日期格式化oracle查询?

[英]How can I format an oracle query with this date?

I tried various alterations to get the right query date format. 我尝试了各种更改以获得正确的查询日期格式。 Below is one of them. 下面是其中之一。 The below date is actually filled in by string substitution from a java program. 以下日期实际上是通过java程序中的字符串替换填充的。 I need to be able to interpret it and run the query. 我需要能够解释它并运行查询。 Currently the query fails with the below error: 目前查询失败,出现以下错误:

[Error] Execution (48: 18): ORA-01841: (full) year must be between -4713 and +9999, and not be 0

SELECT 
 to_date('Mon Jan 01 12:00:00 EST 1990', 'yyyy/mm/dd HH:MI:SS')
 FROM
 duAL

You cant use to_date for timezone. 你不能使用to_date时区。 try this. 尝试这个。

SELECT 
TO_TIMESTAMP_TZ('MON JAN 01 12:00:00 EST 1990', 'DY MON DD HH24:MI:SS TZR YYYY')
FROM
duAL;

我试试,删除了周一美国东部时间

SELECT to_date('Jan 01 12:00:00 1990', 'MON DD HH:MI:SS RRRR') FROM dual 

[ EDIT ] Fixed the error, use TO_TIMESTAMP_TZ it should work. [ 编辑 ]修正了错误,使用TO_TIMESTAMP_TZ它应该工作。

SELECT 
TO_TIMESTAMP_TZ('Mon Jan 01 12:00:00 EST 1990', 'DY MON dd HH:MI:SS TZR yyyy')
FROM
duAL

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM