2017-04-14 64 views
0

我寫的查詢使用下面的查詢如何解決錯誤:ORA-01861:文字不匹配格式字符串

select to_date(strDate,'DD-MON-YY HH24:MI:SS') from TempTableExtra 

長度14的字符串值轉換爲日期,但我得到以下錯誤:

ORA-01861: literal does not match format string 
01861. 00000 - "literal does not match format string" 
*Cause: Literals in the input must be the same length as literals in 
      the format string (with the exception of leading whitespace). If the 
      "FX" modifier has been toggled on, the literal must match exactly, 
      with no extra whitespace. 
*Action: Correct the format string to match the literal. 

列 「strDate」 的值是如像下面

20161104083815 20161104142227 20170206150945 20170206151122 20170206151130 20170306094206 20170328105454

+1

我建議你查閱關於'TO_DATE'如何工作的文檔。因爲你提供的數據顯然與格式字符串不匹配。 – miken32

回答

0

您需要將日期變量的格式相匹配的面膜使用的是:

TO_DATE(「20161104083815」,「YYYYMMDDHH24MISS」)

當心,你的日期格式開始的一年 - 2016年,所以你的面具需要從今年開始--yyyy,等等。

相關問題