我試圖找到2日期之間的天數。 我試着運行下面的查詢,並以ORA-30076錯誤結束。ORA-30076當試圖找到日期之間的日期
查詢,
select extract(day from (sysdate - to_date('2009-10-01', 'yyyy-mm-dd')))
from dual
錯誤是,
Error at Command Line:1 Column:34
Error report:
SQL Error: ORA-30076: invalid extract field for extract source
30076. 00000 - "invalid extract field for extract source"
*Cause: The extract source does not contain the specified extract field.
但是,當我嘗試運行
Select extract(day from sysdate) from dual;
我得到了正確的輸出。
請幫助,如果有人知道爲什麼我得到上述錯誤的原因。
你不需要提取,看看這個:http://stackoverflow.com/questions/1646001/how-can-i-get-the-number-of-days-between-2-dates-in- oracle-11g – mavroprovato
只需使用'date'2009-10-01''而不是to_date。 –
'sysdate - to_date('2009-10-01','yyyy-mm-dd')'就夠了。不需要「提取」。 –