Hello. We currently have a Crystal repository function that calculates the age of a record by subtracting out non work days. Does anyone have a good example of how to do something similar to the below in pls/ql?
downdays = days to substract.
calculates number of days between close and open date
Function (dateTimeVar DT_1, dateTimeVar DT_2, Optional StringVar Proj := "GLBL")
local dateVar X := Date(DT_1);
local dateVar Target := Date(DT_2);
local numberVar DownDays := 0;
While X <= Target
Do ( If (DayOfWeek(X) in [1,7] OR US_Holidays(X, Proj))
then DownDays := DownDays + 1
else DownDays := DownDays + 0;
X := X + 1
(DateDiff ("h", DT_1, DT_2) / 24) - // Total number of days (#2)
DownDays // - Holidays (#1)
// = Number of Business Days