SQL> select 1 from dual where to_date('2003-08-07','yyyy-mm-dd') = '2003-08-07'; 1
----------
1已用时间: 00: 00: 00.31
SQL> select 1 from dual where to_date('2003-08-07','yyyy-mm-dd') = '20030807'; 1
----------
1已用时间: 00: 00: 00.30
SQL> select 1 from dual where trunc(sysdate)='20030807'; 1
----------
1已用时间: 00: 00: 00.20
SQL> select 1 from dual where trunc(sysdate)='2003-08-07'; 1
----------
1已用时间: 00: 00: 00.30
SQL> 根据上面的实验,应该是可以的
----------
1已用时间: 00: 00: 00.31
SQL> select 1 from dual where to_date('2003-08-07','yyyy-mm-dd') = '20030807'; 1
----------
1已用时间: 00: 00: 00.30
SQL> select 1 from dual where trunc(sysdate)='20030807'; 1
----------
1已用时间: 00: 00: 00.20
SQL> select 1 from dual where trunc(sysdate)='2003-08-07'; 1
----------
1已用时间: 00: 00: 00.30
SQL> 根据上面的实验,应该是可以的
dateval date;
val table_a.column1%type;
begin
...
select table_a.column1 into val from table_a where datecolumn = dateval;
dbms_output.put_line(val);
end;
/
两个date类型的变量可以进行比较,但要注意你需要的比较精度
是精确到小时、天还是年
这样的话就需要用trunc()来进行规范