1 回答
TA贡献1876条经验 获得超6个赞
如果END_DT列的数据类型是DATE,那么您的查询将起作用。看来不是,而是VARCHAR2。如果是这样,您必须TO_DATE使用适当的格式掩码对其应用功能才能使其正常工作。例如:
select * From my_records
where to_date(substr(end_dt, 1, 9), 'dd-mon-yy') > sysdate
30-DEC-18 12.00.00.000000000 AM
---------
this makes SUBSTR(end_dt, 1, 9), and its format mask is dd-mon-yy
[编辑]
你说它的数据类型是时间戳。如果是,那么您的查询将起作用。看看这个例子:
SQL> create table test (end_dt timestamp);
Table created.
SQL> insert into test values (systimestamp);
1 row created.
SQL> select * From test where end_dt < sysdate;
END_DT
----------------------------------------------------
02.02.19 20:42:08,375000
SQL>
你能验证它真的是TIMESTAMP(不是看起来像,而是真的是)。通过运行 DESC 命令来做到这一点:
SQL> desc test
Name Null? Type
----------------------------------------- -------- ---------------
END_DT TIMESTAMP(6)
SQL>
添加回答
举报
