ORA-01843:不是有效月份:Oracle错误

时间:2016-01-27 09:09:19

标签: oracle oracle11g

我写了一个下面的oracle查询,但得到的是ORA-01843:不是有效月份:Oracle错误

Fabric

我需要在TIMESTAMP列中仅显示Date但是会出错。请帮忙。

1 个答案:

答案 0 :(得分:2)

您需要删除where子句中的时间戳部分,并在SELECT中使用TRUNC,如下所示:

select distinct info1, info2, trunc(TIMESTAMP) as timestamp 
  from db_1
 where info1 = '3.14' 
   and TRUNC(TIMESTAMP) = to_date('8/19/2015','mm/dd/yyyy');

或者这样做:

select distinct info1, info2, trunc(TIMESTAMP) as timestamp
  from db_1
 where info1 = '3.14' 
   and TIMESTAMP = to_timestamp('8/19/2015 5:58:51.420000 AM','mm/dd/yyyy hh:mi:ss.ff AM');