CREATE OR REPLACE function PRODDTA.jde_date_to_char
( jde_date number,
format_str varchar2 := 'DD/MM/YYYY'
)
return varchar2
is
begin
/* Function to convert dates in JDE to format specified */
return
to_char( jde_date_to_date(jde_date), format_str );
end jde_date_to_char;
CREATE OR REPLACE function PRODDTA.jde_date_to_date
( jde_date number
)
return date
is
begin
/* Function to convert dates in JDE to oracle dates
JDE stores it dates in a 6 digit number field
1st 3 characters is the number of years since 1900
next 3 characters is the day # in the year */
if nvl(jde_date,0) = 0
then
return null;
else
return
to_date(
to_char(
to_number(
substr(to_char(jde_date,'000000'),2,3)
)+1900
)||
substr(to_char(jde_date,'000000'),5,3),
'YYYYDDD'
);
end if;
end jde_date_to_date;