2017-10-19 70 views
0
DECLARE 
    thisyear number(4,0); 
BEGIN 
    thisyear := year(getdate()); 
END; 

回答

0

可以使用EXTRACT功能:

DECLARE 
    thisyear number(4,0); 
BEGIN 
    thisyear := extract(year from sysdate); 
END; 

或者,你可以使用TO_CHAR与格式字符串:

DECLARE 
    thisyear number(4,0); 
BEGIN 
    thisyear := to_number(to_char(sysdate, 'YYYY')); 
END; 
+0

这SQLdevloper是工作,但在表单中出现错误。 “期待下列其中一项时,从符号”FROM“中得到......()* @ $%&.....” – Hussain

+0

@Hussain - 增加了另一种方法。请参阅最新的答案。 – GurV

+0

非常感谢@Gurwinder – Hussain