Hi,

I am trying to write the Oracle equivalent function for isdate() of SQLServer. I have a field in Oracle as varchar2 that contains formated string dates as 'DD-MM-YYYY'. I need to chek to see if the dates are valid before pushing it into Oracle date field.



create or replace function check_dateformat(p_date_input varchar2)
return boolean is lv_date_return DATE ;
begin
lv_date_return := to_date(p_date_input, 'DD-MM-YYYY');
if
substr(p_date_input,1,2) not between '01' and '12'
or
substr(p_date_input,4,2) not between '01' and '31'
or
substr(p_date_input,7,4) not between '1900' and '2050'
or
substr(p_date_input,1,2) = '02' and substr(p_date_input,4,2) = '29'
and round(substr(p_date_input,7,4)/4)*4 <> (p_date_input,7,4)
--length(substr(p_date_input, instr(p_date_input, '-',1,2)+1))<>4
Then
return false;
else
return true;
end if;
exception
When Others then
return false;
end check_dateformat;

Can anyone help? Thanks,
CD