SQL查询错误_Oracle日期格式ORA-01841

1、Oracle日期格式ORA-01841: (full) year must be between -4713 and +9999, and not be 0

这种情况基本上就是要格式化的数据是错的

select trunc(starttime)date1,sum(startmainqty) qty 
from rep_wafer_start_detail 
where starttime>=to_date('2020-10-10','yyyy-mm-dd')
and starttime<to_date('2020-10-20','yyyy-mm-dd')
and bg_id='ICBG' group by trunc(starttime)
-------------错误日期更换--------------------
select trunc(starttime)date1,sum(startmainqty) qty 
from rep_wafer_start_detail 
where starttime>=to_date('&v_start&','yyyy-mm-dd')
and starttime<to_date('&v_end&','yyyy-mm-dd')
and bg_id='ICBG' group by trunc(starttime)
--------------正确日期更换(VB)----------------
where starttime>=to_date('"&v_start&"','yyyy-mm-dd') and starttime<to_date('"&v_end&"','yyyy-mm-dd') 

 不是日期格式的数据,原因:

在进行SQL查询时首先以固定时间带入,再在引用程序中更换为变量,更换过程变量格式错误导致日期格式错误

 

posted @ 2020-10-20 09:39  bellin124  阅读(3718)  评论(0编辑  收藏  举报