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.
******************************************************************************
col a heading "Difference|In WeekDays" format 99,999
select weekday_diff(to_date('Fri, 05 May 2006','DY, dd Mon YYYY'),
to_date('Mon, 15 May 2006','DY, dd Mon YYYY'))a from dual;
Difference
In WeekDays
-----------
7
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.