create or replace function isdate
(p in varchar2)
return varchar2
is
result date;
begin
result:= to_date(p,'yyyy-mm-dd');
return to_char(result,'yyyy-mm-dd');
exception
when others then return '0';
end;
正常的日期返回本身
否则返回0
测试1
select isdate('2014-01-01') from dual
测试2
select isdate('2014-01-33') from dual
-------------
那象你那样这样写不就行吗
你那个报错
create or replace function isdate
(p in varchar2)
return int
is
result date;
begin
result:= to_date(p,'yyyy-mm-dd');
return 1;
exception
when others then return 0;
end;