Number of working Days (Mon-Fri) between two dates?
Has anyone there written - or know of - a query or function to return the number of working days between two dates?
My pseudo code would be a function accepting the two dates and returning a number of working days. Anyone have anything quicker/more elegant/ simpler?
IN (start_date, end_date) OUT (Num_days)
total_days := (end_date - start_date);
count := 1;
LOOP UNTIL start_date = end_date
IF TO_CHAR(start_date,'Dy') IN ('Sat','Sun')
Then add 1 to count
start_date := start_date + 1
num_days := (total_days - count)