I'm trying to exclude weekends and holidays in a date calculation. I'm using formula langage posted in tek-tips but don't think I'm using it correctly.
In the header, I have the field @Holidays
//Holiday Listing formula to go into the report header of the report.
BeforeReadingRecords;
DateVar Array Holidays := [
Date (2010,01,01),
Date (2010,01,18),
Date (2010,06,30),
Date (2010,07,05),
Date (2010,09,06),
Date (2010,11,25),
Date (2010,11,26),
Date (2010,12,23),
Date (2010,12,24),
Date (2010,12,31),
Date (2011,01,17),
Date (2011,07,04),
Date (2011,09,05),
Date (2011,11,24),
Date (2011,11,25),
Date (2011,12,23),
Date (2011,12,26),
Date (2012,01,02),
Date (2012,01,16)
];
0
Then, I have a field called @Business Days
WhileReadingRecords;
Local DateVar Start := date({@Create DateTime});
Local DateVar End := date({@Complete DateTime});
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 );
Weeks + Days - Hol
I don't believe @Business Days is excluding holidays in it's final calculation. I don't think it's considering @Holidays but I don't see why. Thanks for your help.
In the header, I have the field @Holidays
//Holiday Listing formula to go into the report header of the report.
BeforeReadingRecords;
DateVar Array Holidays := [
Date (2010,01,01),
Date (2010,01,18),
Date (2010,06,30),
Date (2010,07,05),
Date (2010,09,06),
Date (2010,11,25),
Date (2010,11,26),
Date (2010,12,23),
Date (2010,12,24),
Date (2010,12,31),
Date (2011,01,17),
Date (2011,07,04),
Date (2011,09,05),
Date (2011,11,24),
Date (2011,11,25),
Date (2011,12,23),
Date (2011,12,26),
Date (2012,01,02),
Date (2012,01,16)
];
0
Then, I have a field called @Business Days
WhileReadingRecords;
Local DateVar Start := date({@Create DateTime});
Local DateVar End := date({@Complete DateTime});
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 );
Weeks + Days - Hol
I don't believe @Business Days is excluding holidays in it's final calculation. I don't think it's considering @Holidays but I don't see why. Thanks for your help.