create or replace function toNormDate(adate in number) return date
is
god char(5);
mes char(3);
den char(3);
begin
if adate < 32 then
return null;
end if;
god := to_char(adate/65536, '9999');
mes := to_char(bitand(adate, 65280)/256, '09');
den := to_char(bitand(adate, 255), '09');
return(to_date(god || '/' || den || '/' || mes, 'YYYY/DD/MM'));
end toNormDate;