select * from TNAME where
to_char (tran_date,'YYYY') = 2018
答案 0 :(得分:1)
提取天?您的代码建议年,所以 - 我将使用年。以下是一些选项:
SQL> select count(*) from dual where extract(year from sysdate) = 2018;
COUNT(*)
----------
1
SQL> select count(*) from dual where to_char(sysdate, 'yyyy') = '2018';
COUNT(*)
----------
1
SQL> select count(*) from dual where trunc(sysdate, 'yyyy') = date '2018-01-01';
COUNT(*)
----------
1
SQL>