function CF_DIF_DATEFormula return VARCHAR is
days number;
hr number;
mm number;
vTmp_ret varchar2(100);
temp varchar2(100);
begin
days := trunc(:startup_date) - trunc(:break_date);
hr := trunc((:startup_time - :break_time)/3600) ;
mm := trunc( mod((:startup_time - :break_time) , 3600 ) / 60 ) ;
temp := ' ';
IF trunc(:startup_date) = trunc(:break_date) THEN
vTmp_ret := (replace(to_char(hr,'99')||' ชม '||to_char(mm,'99')||' นาที',' ',''));
ELSIF trunc(:startup_date) <> trunc(:break_date) THEN
IF :startup_time = :break_time THEN
vTmp_ret := (replace(to_char(days,'99,999')||' วัน ',' ',''));
ELSIF :startup_time <> :break_time THEN
IF :break_time < :startup_time THEN
days := days;
hr := hr ;
mm := mm ;
ELSIF :break_time > :startup_time THEN
days := days -1;
hr := trunc((86400-(:break_time - :startup_time))/3600) ;
mm := trunc( mod((:break_time - :startup_time) , 3600 ) / 60 ) ;
END IF;
----------------------------------------------------------------------------------------------------------------
IF days = 0 THEN
vTmp_ret := (replace(to_char(hr,'99')||' ชม '||to_char(mm,'99')||' นาที',' ',''));
ELSE
vTmp_ret := (replace(to_char(days,'99,999')||' วัน '||' '||to_char(hr,'99')||' ชม '||to_char(mm,'99')||' นาที ',' ',''));
END IF;
----------------------------------------------------------------------------------------------------------------
END IF;
END IF;
return(vTmp_ret);
end;
Thank you so much
ตอบลบ