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查詢時首先以固定時間帶入,再在引用程序中更換為變量,更換過程變量格式錯誤導致日期格式錯誤

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM