I am trying to calculate number of days between dates which i have a formula for (I believe this is the Ken Hamady formula):
WhileReadingRecords;
Local DateVar Start := DATE({EVENT_DATTIM}); // place your Starting Date here
Local DateVar End := CurrentDate +1; // place your Ending Date here
Local NumberVar Weeks;
Local NumberVar Days;
Local Numbervar Hol;
DateVar Array Holidays;
Weeks:= (Truncate (End - dayofWeek(End) + 1
- (Start - dayofWeek(Start) + 1)) /7 ) * 5;
Days := DayOfWeek(End) - DayOfWeek(Start) + 1 +
(if DayOfWeek(Start) = 1 then -1 else 0) +
(if DayOfWeek(End) = 7 then -1 else 0);
Local NumberVar i;
For i := 1 to Count (Holidays)
do (if DayOfWeek ( Holidays ) in 2 to 6 and
Holidays in start to end then Hol:=Hol+1 );
This works great but I need to skip days when one of the dates being calculated matches a condition in another field. One of the tables I'm using has a column 'Suspended Code'. If one of those dates meets one of the suspended code reasons then don't count that day in the calculation. I hope I explained this ok. Thanks in advance!
Weeks + Days - Hol
WhileReadingRecords;
Local DateVar Start := DATE({EVENT_DATTIM}); // place your Starting Date here
Local DateVar End := CurrentDate +1; // place your Ending Date here
Local NumberVar Weeks;
Local NumberVar Days;
Local Numbervar Hol;
DateVar Array Holidays;
Weeks:= (Truncate (End - dayofWeek(End) + 1
- (Start - dayofWeek(Start) + 1)) /7 ) * 5;
Days := DayOfWeek(End) - DayOfWeek(Start) + 1 +
(if DayOfWeek(Start) = 1 then -1 else 0) +
(if DayOfWeek(End) = 7 then -1 else 0);
Local NumberVar i;
For i := 1 to Count (Holidays)
do (if DayOfWeek ( Holidays ) in 2 to 6 and
Holidays in start to end then Hol:=Hol+1 );
This works great but I need to skip days when one of the dates being calculated matches a condition in another field. One of the tables I'm using has a column 'Suspended Code'. If one of those dates meets one of the suspended code reasons then don't count that day in the calculation. I hope I explained this ok. Thanks in advance!
Weeks + Days - Hol