create or replace function strFormatDate(i_datestr in varchar2) return date is begin if i_datestr is null or trim(i_datestr) = '' then return null; end if; return to_date(i_datestr,'yyyy-MM-dd'); end strFormatDate;