Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
create or replace function weekday_diff(dt1 date,dt2 date) return number is
curr_dt date;
day_cnt number := 0;
date_beg date;
date_end date;
begin
date_beg := least(dt1,dt2);
date_end := greatest(dt1,dt2);
curr_dt := date_beg;
while curr_dt <= date_end loop
if to_char(curr_dt,'DY') not in ('SAT','SUN') then
day_cnt := day_cnt + 1;
end if;
curr_dt := curr_dt + 1;
end loop;
return day_cnt;
end;
/
Function created.
select weekday_diff(to_date('01/01/2007','mm/dd/yyyy')
,to_date('02/05/2007','mm/dd/yyyy')) diff from dual;
DIFF
-------
26