Ecco una semplice funzione per calcolare la
differenza tra due date.
create or
replace function FUN_DATEDIFF (
dateFrom in date,
dateTo in date,
interval in char
)
return number
AS
result
number;
begin
--
select
case
lower(interval)
when
'm' then
round(MONTHS_BETWEEN(dateTo, dateFrom))
when
'd' then
round(dateTo - dateFrom)
when
'y' then
round(MONTHS_BETWEEN(dateTo, dateFrom)/12)
else
0
end into
result
from
dual;
--
return(result);
--
end
FUN_DATEDIFF;
Powered By IMHO